Explore
ProGrad Programs
About Us

Edit
Reply




Edit

How DHCP server dynamically assigns IP address to a host?

Published on 07 Mar 2020

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.



Working of DHCP


  • DHCP provides static and dynamic address allocation which can be automatic or manual. Static addresses are created manually while dynamic addresses are created automatically.


  • So when a DHCP client requests to its associated server, the servers first find its static database, and if the entry is matched then the IP address of the client is returned. But if the entry is not matched then it uses the concept of Dynamic Address Allocation where DHCP has a pool of available IP addresses, assigns an address from the pool to DHCP client, and adds the entry to the dynamic database.


  • The addresses assigned from the pool are temporary addresses and on expiry of lease period, the client needs to either stop using that IP address or renew that IP address, as per instruction of server. 


  • It is an application layer protocol used by hosts for obtaining network setup information. The DHCP is controlled by DHCP server that dynamically distributes network configuration parameters such as IP addresses, subnet mask, and gateway address.

 


Disadvantages of manually Configuring the host: 


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.

 

Configuring a host using DHCP


To configure a host, we require the following things:


  • Leased IP address – IP address to a host which lasts for a particular duration.
  • Subnet Mask – The host can know on to which network it is connected.
  • Gateway address – The Gateway is the Internet Service Provider that connects the user to the internet. The Gateway address lets the host know where the gateway is to connect to the internet.

 

DHCP Entities


  • DHCP server: It automatically provides network information such as IP address, subnet mask, gateway address on lease. Once the duration gets expired, that network information will be assigned to another machine. The available IP addresses are stored in a data storage.


  • DHCP client: Any node which requests an IP address allocation to a network becomes a DHCP client.


  • DHCP Relay Agent: In case, we have only one DHCP server for multiple LAN’s then this Agent which is present in every network forwards the DHCP request to DHCP server. So, we can configure multiple LAN’s with single server using DHCP relay agent.


How does DHCP server assign an IP address to a host?


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.


References:


For reference to DHCP protocol, click here

 

 

If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in
Explore 'computer networks'
Articles Mock Tests