DHCP – Dynamic Host Configuration Protocol
An IP address is the unique identity of a host or a computer device while linked to any network. In most of the cases when you join your computer to the LAN or the internet, you’ll notice that the IP address and other data including subnet mask and default gateway IP address are allocated to your computer automatically. This is done using DHCP. DHCP stands for Dynamic Host Configuration Protocol.
As the name suggests, DHCP is used to govern the network configuration of a host through a remote server. DHCP functionality comes fitted as a default feature in most of the current operating systems. DHCP is an excellent substitute to the time-consuming manual assigning of network settings on a host or a network device.
DHCP works on a client-server model. Being a protocol, it has its own group of messages that are sent between client and server.
- When the client device boots up or is linked to a network, a DHCPDISCOVER message ist transmitted from the client to the server. As there is no network configuration data on the client so the message is transmitted with 0.0.0.0 as the source address and 255.255.255.255 as the destination address. If the DHCP server is located on the local subnet, then it directly accepts the message. If it is on another subnet then a relay agent connected on client’s subnet is used to pass on the message to DHCP server. The transport protocol used for this type of communication is UDP and the port number used is 67. The client enters the initializing phase during this step.
- When the DHCP server takes the DHCPDISCOVER request message then it answers with a DHCPOFFER message. As already explained, this message encompasses all the network configuration settings needed by the client. For example, the address field of the message will contain the IP address to be assigned to the client. Likewise, the subnet mask and gateway information is added in the options field. Also, the server fills in the client MAC address in the 16-byte chaddr field. This message is sent as a broadcast (255.255.255.255) message for the client to receive it straight or if DHCP server is located in the different subnet then this message is sent to the relay agent that decides if the message is to be passed as unicast or broadcast. In this situation, UDP protocol is again used at the transport layer with destination port as 68. The client enters selecting phase during this step.
- The client then creates a DHCPREQUEST message in response to DHCPOFFER message and sends it to the server signifying it wants to accept the network configuration sent in the DHCPOFFER message. If there exist multiple DHCP servers that received DHCPDISCOVER then the client could also receive multiple DHCPOFFER communications. But, the client replies to only one of the messages by populating the server identification field with the IP address of a specific DHCP server. All the messages from other DHCP servers are indirectly declined. The DHCPREQUEST message will still encompass the source address as 0.0.0.0 as the client is still not permitted to use the IP address passed to it through DHCPOFFER message. The client enters requesting phase during this step.
- Once the server accepts DHCPREQUEST from the client, it sends the DHCPACK message signifying that now the client is permitted to use the IP address assigned to it. The client enters the bound phase during this step.