The Dynamic Host Configuration Protocol (DHCP) server dynamically assigns IP address, subnet mask, default gateway, DNS servers to a computer on a network. On a small network, the router is typically the DHCP server while on a larger network, a dedicated computer might be configured to perform the DHCP role. Computers on a network without a DHCP server will have to be manually configured with the above network parameters before they can use the network.
How does it work?
Basically, it boils down to 4 distinct phases which are Discovery, Offer, Request and Acknowledge.
- Discovery phase
- The computer seeking an IP address, i.e. the DHCP client, will broadcast a DHCPDISCOVER message using the broadcast IP address of 255.255.255.255 that will be readable by all computers on that same network.
- Offer phase
- Upon receiving the DHCPDISCOVER message, the DHCP server allocates an IP address from its pool of available IP addresses and send the DHCP client a DHCPOFFER message telling the client the IP address and other relevant network parameters that the DHCP server is offering to the DHCP client.
- Request phase
- Upon receiving the DHCPOFFER message, the DHCP client will broadcast its acceptance of the offered network parameters using a DHCPREQUEST message.
- Acknowledge phase
- Upon receiving the DHCPREQUEST message, the DHCP server will send back a DHCPACK to acknowledge the acceptance of the IP address and also send back information like lease duration along with other network parameters required by the client.
After the DHCP client has obtained the new IP address, it will conduct a check to make sure that no other computer on the same subnet is using that IP address. This normally happens if the other computer with the same IP address is manually configured by someone. When that happens, the computer will usually inform the user that there is an IP address conflict and it’s up to the user to locate and fix the issue.