Tuesday, September 13, 2022

How DHCP works?

Dynamic Host Configuration Protocol (DHCP) is a network service for automatically assigning IP Addresses to clients on a network. It follows a server-client architecture where the client requests a DHCP Server to get an IP Address. Most routers have a DHCP server built-in but we can use our own DHCP Server too.


When the computer boots up it doesn’t have an IP Address (Assuming it doesn’t have static IP Addressing configured, which most of the machines don’t have). It sends a broadcast (on the MAC Address with all F’s) called a DHCP Discover. DHCP Servers are designed to respond to such broadcasts.


They then send unicast traffic known as the DHCP Offer back to the requesting client. This DHCP Offer typically contains the Assigned IP Address, the Default Gateway’s IP Address, and the DNS Server’s IP Address.


The client on receiving the Offer sends a DHCP Request to the DHCP Server acknowledging that it has accepted the information given to it by the server.


DHCP Servers keep a record of the assigned IP Addresses to prevent double assignment or IP Address Collisions.


Since DHCP Servers respond to broadcast, they must be present on the local network and there shouldn’t be more than 1 DHCP Server on a local network.


Allocation Methods for DHCP

Following are the two allocation methods for a DHCP Server:


Manual: In this method, the IP Address is given on the basis of the MAC Address. This ensures that a particular machine gets a fixed IP Address as its IP Address is then tied to its MAC Address. The DHCP Server sends a constant configuration to the client depending on its MAC Address in this type of allocation.

Automatic: In this method, the IP Addresses are assigned automatically by the DHCP Server on a first-come, first-served basis from a pool of addresses. It can be further divided into two categories based on the Lease Time – The time for which an IP Address is assigned to a client.

Fixed Lease Time: When a DHCP client is no longer on the network for a specified period, the configuration is expired and released back to the address pool for use by other DHCP Clients. The client has to renegotiate to keep the previous IP Address.

Infinite Lease Time: This has the effect of permanently assigning an IP Address to a client.



references

https://www.linuxfordevices.com/tutorials/ubuntu/dhcp-server-on-ubuntu

No comments:

Post a Comment