Explain in detail, the DHCP Client/Server Communication?
DHCP Client/Server Communication
The DHCP client is listening on UDP port 68.
The DHCP server is listening on UDP port 67.
• Client broadcasts a DHCPDISCOVER, sends it’s MAC address and requests an IP address and it’s
desired options.
• Based on MAC address, server checks client definitions and unicasts or broadcasts a DHCPOFFER,
offering the client an IP address.
• At the same time, if there are multiple DHCP servers on the network, the client may receive offers from
those other DHCP servers.
• The client will then select the first valid offer, it is up to the logic in the client’s DHCP software as to what
it considers the first valid offer, typically it is the first offer that it received, but some DHCP clients will
look for specific options that have been returned and only accept the offer if the options were returned.
• Client broadcasts a DHCPREQUEST indicating in the DHCPREQUEST the DHCP server it has selected.
• If the DHCP server was not selected in the DHCPOFFER, it will return reserved IP address to back to the
pool.
• If the DHCP server’s offer was accepted, it marks the IP address as leased and unicasts/broadcasts a
DHCPACK to the client
• Client generates an ARP request to check that the IP address is not already in use.
• Assuming the client didn’t get a response to the ARP, therefore the address is not in use on the subnet
already, the client will use the IP address.
What if the client had a response to the ARP, indicating the IP address the DHCP server has just provided is already in use on the network?
• The client should broadcast a DHCPDECLINE indicating the address is already in use
• The DHCP server will then mark the address as abandoned in it’s database
• The client will start from the DHCPDISCOVER again
If the client did not send a DHCPDECLINE message to the DHCP server and simply tried to request another IP address, the DHCP server will continue to hand back the same IP address, as that is what the DHCP server now has in it’s leases table, the mapping for the client’s MAC address against the in-use IP address.