Dynamic Host Configuration Protocol (DHCP) provides IP address and other configuration information like subnet mask, default gateway, WINS and DNS server address to network clients. DHCP allocates IP addresses dynamically to the clients, known as a lease for a period called lease period.
DHCP lease-generation is 4 step process called DORA which expands as below:
D – Discover
O – Offer
R – Request
A – Acknowledgement
The working process is as under:
1. The DHCP client broadcasts a DHCPDISCOVER packet in the subnet.
2. Once DHCP Server receives DISCOVER packet, it replies with DHCPOFFER packet. This packet is broadcast and contains a potential IP address for the client.The client might receives DHCPOFFER packet from multiple DHCP servers ( if they exist in subnet).
3. The client then broadcasts a DHCPREQUEST that contains a server identifier. Since this broadcast packet reaches all DHCP servers, they come to know which server’s DHCPOFFER the client has chosen to accept. In case client received multiple DHCPOFFER, it selects the server that made the fastest response to its DHCPDISCOVER which typically is the DHCP server closest to the client.
4. Once DHCP servers receive the DHCPREQUEST they use server identifier to know if their offer is accepted or not. The chosen server stores the IP address client information in the DHCP database and broadcasts DHCPACK message. If for some reason, the DHCP server cannot provide the address that was offered in the initial DHCPOFFER, the DHCP server sends a DHCPNAK message.
I will discuss about conditions resulting DHCPNAK in some other blog.
Let’s discuss these steps in more detail. For sake of clarity I am using diagram below:
As per diagram let’s take example of DHCP server whose IP address is A and MAC address is AA (I am using A and AA for sake of simplicity to avoid writing 4 octets of IP and 12 Hexadecimal bits for MAC address). There is a client looking for IP address so don’t have any IP but its MAC address is BB. Steps of DORA process are as under:
1. Client will broadcast DISCOVER packet to 255.255.255.255 which is broadcast IP. It will use 0.0.0.0 as source IP because it doesn’t has any IP yet. On frame it will use broadcast MAC address FF-FF-FF-FF-FF-FF as destination while use its own MAC address as source.
2. Once DHCP server receives DISCOVER packet, it will broadcast OFFER packet on 255.255.255.255 IP as client don’t have any IP. Since server has received MAC address of client from DISCOVER packet it will use it as destination MAC. So, as per our example it will be BB. Hence, OFFER frame is unicast.
With OFFER packet several other information also come as per configuration like DHCP server identifier, potential IP and others
3. Once client receives OFFER it broadcasts REQUEST packet on 255.255.255.255. It uses destination MAC as FF-FF-FF-FF-FF-FF. In case, multiple DHCP servers have sended OFFER packet, REQUEST packet will reach to all of them. This packet has DHCP server identifier which is used by servers to verify whether their IP is chosen or not. However, there is a chance that the transaction related to offer selected by client couldn’t complete successfully. The client then try to send a REQUEST to different Server Identifier. So, “rejected” servers will wait for a while before offering a previously-offered lease to another client.
4. Once Server receives REQUEST packet, it will send ACK packet to client. In destination address it will use broadcast IP address but unicast MAC address i.e BB as per our example. Hence, will be received by intended client only.
Here is the summary:
DISCOVER OFFER REQUEST ACK
SOURCE IP 0.0.0.0 A 0.0.0.0 A
SOURCE MAC BB AA BB AA
DESTINATION IP Broadcast Broadcast Broadcast Broadcast
DESTINATION MAC Broadcast BB Broadcast BB
NETWORK LAYER Broadcast Broadcast Broadcast Broadcast
DATALINK LAYER Broadcast Unicast Broadcast Unicast
Broadcast IP – 255.255.255.255
Broadcast MAC – FF-FF-FF-FF-FF-FF
So, this is all in this blog. Have a very nice day !!