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 !!
Please clarify: During the DHCP DORA process, I thought that only DHCPDISCOVER was a broadcast. Based on what I thought, DHCPOFFER, DHCPREQUEST and DHCPACK are not broadcasts because when the client initiates the process by sending out a boradcast, the DHCP server responds to the client directly.
LikeLike
As I have clarified in blog, for understanding complete process subcategories communication on L2 and L3. Entire DORA is broadcast on L3 however Offer and Ack are unicast on L2.
LikeLike
Please clarify: During the DHCP DORA process, I thought that only DHCPDISCOVER was a broadcast. Based on what I thought, DHCPOFFER, DHCPREQUEST and DHCPACK are not broadcasts because when the client initiates the process by sending out a boradcast, the DHCP server responds to the client directly.
LikeLike
Please check answer above 🙂
LikeLike
ok
LikeLike
Wow , I was in seeking of such a well explained, Finally found it.
Thank You Vinit Sir
Regards,
Hekmatullah Hamidy
LikeLike
Good to know that it helped…
LikeLike
Would dora process reamains same in case if dhcp relay agent is used ?
LikeLike
There is slight deviation as relay agent acts as mediator between DHCP server and client. Although client will broadcast DISCOVER and REQUEST packet, it will be unicasted to server by relay agent. Similarly, server will unicast OFFER and ACK packet which will be broadcasted to client by relay agent. You may check here for more details. http://www.netmanias.com/en/post/techdocs/6000/dhcp-network-protocol/understanding-dhcp-relay-agents
Thanks for asking and hope this will help. 🙂
LikeLike
Hi Vinit ji!! I found this very helpful as I am in learning stage..Thank you very much!! But the above all explanation seems like, keeping switch in mind (unicasting to particular MAC address) What about if there is router in place of switch?
LikeLike
Thanks sir and its pleasure to know that it helped. If you will put router in between it will stop broadcast packets. So, you need to use relay agent.
LikeLike
Thanks Vinit Sir for good information. Can you please tell something about GARP role in DHCP.
LikeLike
Thanks for visiting sir. Sure will soon update for GARP.
LikeLike
Thanks sir Thank’s for giving the valuable information for learner.
LikeLike
Good one, Mr.Vinit
LikeLike
Simple and discreet explanation. Best individual Blog so far on DCHP I have eread
LikeLike
Happy to know that it helped. Thanks for writing.
LikeLike
Hi Vinit,
Very good explanation and summary in simple language.
Regards,
Akshay
LikeLike
Hi Vinit, in DHCP REQUEST packet when a Client know the IP of DHCP Server, why does it broadcast the packet?
LikeLike
It needs to broadcast because its possible to have more than one DHCP server in network. To select one of them and to inform others which DHCP server is selected, client need to broadcast. Hope it helps.
LikeLike
DHCP is mostly asking in an interview (Domestic and MNC companies).
And
How to operate DHCP or DHCP server and what is the relation between SERVER and CLIENT and DORA process.
Thanks for sharing this topic in detail.
LikeLiked by 1 person
From this, We can clarify that what is DHCP and how its function in networking. DHCP is mostly asking in an interview (Domestic and MNC companies). Thanks for sharing this article with me and whole people.
LikeLike
Thanks a lot , i was really confused regarding Offer and Ack , thanks for making it simple to understand
LikeLike
Hi Vinit Sir,
I have below scenario
Client —Gateway—DHCP Server
Will my gateway keep Client’s MAC in the header or change it with its own while sending it to DHCP server. If it changes then why DHCP server has MAC of client instead of the Gateway, becasue gateway is the one who is communicating with DHCP for initial process
LikeLike
Client MAC address is used during communication. Gateway(relay agent) send a unicast packet to DHCP server on behalf of client. In this packet it keeps the client MAC and its downlink IP as relay agent IP. This is how DHCP server has record of client MAC. Hope this helps.
LikeLike
Could you please explain more about what happens once DORA is completed, so how the client machine will check if there any same IP assigned in the same network or not?
LikeLike
You can check my other blog on the subject:
LikeLike
https://vinitpandey.com/2018/10/14/sccm-pxe-deep-dive/
LikeLike
what about the ports?
the sender port and receiver port?
LikeLike
Check if my other post helps: https://vinitpandey.com/2018/10/14/sccm-pxe-deep-dive/
LikeLike
Helpful article.
LikeLike
HI Very Useful post
LikeLike