DHCP is an abbreviation of Dynamic Host Configuration Protocol, It is an application layer protocol used by host to automate the configuration of the network. It distributes the IP address for the network, subnet mask, and gateway address
What is Dynamic host configuration protocol?
- Dynamic – Automatically
- Host – Any computer that is connected to the network
- Configuration – To configure a host means to provide network information(ip address,subnet mask,Gateway address) to a host
- Protocol – Set of rules
Summing up, a DHCP server dynamically configures a host in a network.
Configuring host using DHCP
- Leased IP Address – IP address to a host for a particular duration, for example, a day, an hour
- Subnet Mask – For the network to know which network it is on
- Gateway Address – This is the address for the Internet Service Protocol to enable the hosts to connect to the internet. This is used by hosts to connect to the internet
How DHCP server assigns IP address to a host?
- DHCPDISCOVER: When a new node is connected to the network, it broadcasts the DHCPDISCOVER message which contains the source address as 0.0.0.0 to every node on the network including server. DHCP server on receiving the message, returns the DHCPOFFER message to the requested host which contains the server address and new IP address to the node.
- DHCPOFFER: If there are multiple servers on the network, host receives multiple DHCPOFFER messages. It is up to the host to select a particular message.
- DHCPREQUEST: The requested host on receiving the offer message, it again broadcasts the DHCPREQUEST 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.
- DHCPACK : If the address is assigned , it marks the IP address in the storage as unavailable to ensure consistency. Now, the server sends DHCPACK 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 DHCPNAK to the requested host indicating that the IP address is assigned to some other machine.
- DHCPRELEASE : And finally, If the host wants to move to other network or if it has finished its work, it sends the DHCPRELEASE 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 machine.