What is DHCP Protocol and How does it Work

DHCP, Dynamic Host Control Protocol, is a Protocol that operates at Application layer and Automatically assigns IP Addresses to requesting Hosts. DHCP eliminates the manual task by a network Administrator. It also provides a central database of devices that are connected to the network and eliminate duplicate resource assingments. DHCP uses UDP (User Datagram Protocol) to send its request messages to the DHCP Server on Port number 67.

A DHCP Server can provide to a host alot of information when the host is requesting an IP address from a DHCP Server. Here’s a list of the information a DHCP Server can provide:
  • IP Address
  • Subnet Mask
  • Domain Name
  • Default Gateway (routers)
  • DNS
  • WINS information
How DHCP Server is Discovered by Client to get IP address?
The client broadcasts messages on the physical subnet to discover available DHCP servers. Network administrators can configure a local router to forward DHCP packets to a DHCP server from a different subnet. This client-implementation creates a User Datagram Protocol (UDP) packet with the broadcast destination of 255.255.255.255 or the specific subnet broadcast address. Addresses in the Packet for DHCP Server Discovery can be as follows;
Source IP = 0.0.0.0
Source Port = 0
Destination IP = 255.255.255.255
Destination Pot = 67
A DHCP client can also request its last-known IP address. If the client remains connected to a network for which the IP is valid, the server may grant the request.
DHCP Offer
When a DHCP server receives an IP lease request from a client, it reserves an IP address for the client and extends an IP lease offer by sending a DHCPOFFER message to the client. This message contains the client’s MAC address, the IP address that the server is offering, the subnet mask, the lease duration, and the IP address of the DHCP server making the offer. Source and Destination addresses in the server’s DHCP Offer message are as follows;
Source IP = 192.168.1.1
Source Port = 67
Destination IP = 255.255.255.255
Destination Pot = 68
DHCP Request
A client can receive DHCP offers from multiple servers, but it will accept only one DHCP offer and broadcast a DHCP request message. Based on the Transaction ID field in the request, servers are informed whose offer the client has accepted. When other DHCP servers receive this message, they withdraw any offers that they might have made to the client and return the offered address to the pool of available addresses. The DHCP request message is broadcast, instead of being unicast to a particular DHCP server, because the DHCP client has still not received an IP address. Also, this way one message can let all other DHCP servers know that another server will be supplying the IP address without missing any of the servers with a series of unicast messages.
DHCP Acknowledgement
Upon Receiving DHCP acknowledgment message on server, server sends IP Address, lease duration and other info to the client that requrested, and IP address Assignment process to the client by DHCP Server is completed.