DHCP stands for Dynamic Host Configuration Protocol. Dynamic Host Configuration Protocol(DHCP) is a networking protocol which assigns a unique IP address to each IP based hosts for a specific time period known as lease period.
When connected to a network. a host can be configured either manually i.e., by the network administrator or by the DHCP server. Manual configuration is quite easy in case of home networks. Whereas in the large networks, the network administrator might face many problems. Also, the manual configuration is easily prone to mistakes. For example, a Network administrator might assign an IP address which is already assigned. Thus, causing difficulty for both administrator as well as neighbors on the network.
So, here comes the use of DHCP server. Before discussing how DHCP server works, let us go through the DHCP entities.
To configure a host, we require the following things:
1. Whenever a new node is connected to a network, it broadcasts the DHCP DISCOVER message which contains the source address as 0.0.0.0 to every node on the network including the server. DHCP server on receiving the message, responds with DHCP OFFER message to the requested host which has the server address and new IP address to the node.
2. If there are multiple servers on a network, the host receives multiple DHCP OFFER messages.
3. On receiving the offer message the requested host broadcasts the DHCP REQUEST message on the network with the address of the server whose offer message is accepted by the host. The server which pertains to that server address sent by the host checks whether the address to be assigned to the node is available in the data storage.
4. If the address is assigned, it marks the IP address in the storage as unavailable to ensure consistency. Now, the server sends DHCP ACK packet to the requested host which contains network information (IP address, subnet mask, gateway address). In case, if the address is assigned to other machine meanwhile, then the server sends the packet DHCP NAK to the requested host indicating that the IP address is assigned to some other machine.
5. Finally, If the host wants to move to other network or if it has finished its work, it sends the DHCP RELEASE packet to the server indicating that it wants to disconnect. Then the server marks the IP address as available in the storage so that it can be assigned to other machines.
For reference to DHCP protocol, click here