Why you need DHCP (Dynamic Host Configuration Protocol) and how it works

The first draft of DHCP was written in October 1993. Lets time travel and go to a time where there is no DHCP. Lets have a look at the why you need DHCP. It is very important as it provide the machines their identity to be on the network grid. DHCPD is a server for dhcp

Problems faced

When there were no DHCP people has to manually request for the following things:-

  1. IP Address
  2. Network Subnet mask
  3. Gateway Address
  4. DNS name servers ( For converting Domain name to IP address)
    It was tedious process to get these things. These things will be issued for you some period of time (for example 1 year) and if you want to use the network for only two months then these are being unused for the rest 9 months. This was a bad example for utilisation of resources and also increasing the manual overhead of maintaining the free IP address and which address are given to whom.

Solution

To solve these issues DHCP comes into the pictures. It works over UDP (User Datagram Protocol). It eases the process of distributing the IP address to the nodes. The overall steps are very simple. Whenever the host wants to connect to the network it follows the following the simple steps.

  • Host broadcasts to the network on (255.255.255.255) over UDP from port 67 on client to 68 on the server. This phase is called (DHCP Discover).
  • DHCP server takes out the free IP and sends its configuration to the host DHCP Offer.
  • Host accepts the configuration and sends the server that i have accepted that configuration (DHCP Request).
  • DHCP server updates itself and acknowledges about previous request (DHCP Ack) Voila, your system gets new IP address but wait what about the lease period. The lease period is defined in the DHCP Configuration which it receives from the server. The steps to renew the lease period are below
  • For lease extention: Our host machine again sends the request to the DHCP server to increase the lease just before expiration of lease time (**DHCP Request **).
  • DHCP server acknowledges the request (DHCP Ack) and increases the lease. Now you have increased your lease period.
    If you plan to get out of network then host requests a DHCP Release to the server. Now server will take your IP and put it on its free pool to distribute this IP to another Host. Well this is generally a graceful way to leave the network. Generally the lease gets expired and the IP returns into the free pool.

Well, this is an efficient way to implement IP distribution and thus removes all manual overhead. It was a great protocol that sits at the root of modern-day cloud infrastructure and does a very important job of assigning IPs to them. Why because if you don’t get IP you are out of the network grid.

If you like the article please share and subscribe.


Rahul Sinha

Rahul is a full stack engineer, loves FIFA and Itachi Uchiha and a go to guy for your javascript problems.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Are you preparing for DevOps and SRE Interview?

Here is a book for you.


Interview preparation and interview questions for DevOps and SRE






A good reads for last-minute preparations for handling DevOps and SRE interviews at companies like LinkedIn, Visa, Atlassian, etc.