DHCP: Dynamic Host Configuration Protocol

Suppose, you own a cyber cafe and you have a network in which there are 5 computers. Now you want to add a new computer to the network. So you configure the IP configuration on the computer and assign a static IP address to it followed by the subnet mask, default gateway, and DNS server address. 

Later, you thought of increasing your business and bought 10 more computers. Now to add the newly bought 10 computers, you need to configure the IPs for each and every one of them. You are a smart guy so you configured 10 random IPs to these computers. But now when you start these computers, one of the computers was not able to connect to the network. That's bad !!

This happened due to the IP conflict. In a network it is very important to have unique IP addresses for every device connected. But in your case two computers in the network mistakenly had the same IP address. To avoid this cumbersome activity and to restrict your network from IP conflict you should use a DHCP server.

DHCP to the rescue

DHCP is a network management protocol where a DHCP server assigns an IP address and other configuration parameters to each device on a network so that they can communicate using the IP address. It basically operates as a service that runs on a router.

The DHCP server assigns dynamic IP addresses, subnet mask, default gateway, DNS server address, etc. to the connected devices. It provides the IP address from the IP pool which has a range of IP addresses depending on the class of subnetwork. For small networks, class C subnet is used which gives a range of 254 host addresses. This means we can add up to 254 devices on a network. For large networks we can use class A and B subnets. We will discuss them sometime later.

An IP address on lease

DHCP assigns an IP address on lease to a connected device. This means the device itself does not own the IP address. A lease is defined as the time frame for which an IP is assigned to a device. This mechanism is used to be able to reuse IP addresses present in the pool.

You can check the details on cmd by typing: ipconfig /all

Suppose a DHCP server has a range of 5 IP addresses and has 5 computers in the network. So it assigns one IP to every computer but if one of them is taken out, it takes the IP address with it. Now the DHCP has only 4 IP addresses left and if another computer is added to the network it won't have any IP address left to assign.

To overcome this problem the IP address is given on lease which expires after the assigned time frame. Once the lease is expired the computers ask for IP address renewal and if any computer doesn't ask for renewal in case it has been taken out of the network, the IP address is taken back. That's why these IPs are called dynamic IP addresses.


DHCP works on broadcasting. It uses UDP for communication. It is just like radio broadcasts in which the sender sends the message to all the receivers at the same time. The same technique is applied in DHCP. As a device that needs to be assigned an IP address cannot be identified without an IP address, the DHCP server has to send and receive broadcast messages on UDP port.

UDP port number 68 is the destination port for a DHCP-server and UDP port number 67 is used by the client.

DHCP handshake

  1. Discover: A DHCP-client sends a broadcast message (aka DHCP discover message) with a request "I need an IP-address" to all the devices on the network.
  2. Offer: A DHCP-server catches it and sends back also a broadcast message "I have an IP-address x.x.x.x, do you want it?"
  3. Request: The DHCP-client receives the message and broadcasts another one: "Yes, I want the address x.x.x.x".
  4. Acknowledge: The DHCP-server answers by broadcasting DHCP ACK "Ok, then x.x.x.x belongs to you until the lease expires".

Address Reservation

This is a technique in which a user can assign a permanent/static IP address to a particular device in the network. It is a specific IP address within a DHCP scope that is permanently reserved for leased use to a specific DHCP client. This technique is generally used for more important devices in the network such as routers, network printers, servers, etc.

A reservation consists of the following information:

 Element Description
 Reservation name Name that the administrator assigns
 IP Address The IP address from the scope for the client
 MAC Address Client’s Media Access Control(MAC) address
 Description A description that the administrator assigns
 Supported  DHCP reservation, Boot Protocol (BOOTP), or both  

Advantages of DHCP

  • It relieves the network administrator of a great deal of manual configuration work.
  • The ability for a device to be moved from network to network and to automatically obtain valid configuration parameters for the current network can be of great benefit to mobile users.
  • Because IP addresses are only allocated when clients are actually active, it is possible, by the use of reasonably short lease times and the fact that mobile clients do not need to be allocated more than one address, to reduce the total number of addresses in use in an organization.

Disadvantages of DHCP

  • It uses UDP, which is an unreliable and insecure protocol
  • DHCP is not inherently secure, and if malicious actors access the DHCP server, they can wreak havoc.


Popular posts from this blog

What happens when you watch stuff on Netflix?

How YouTube uploads and streams billions of videos with ease?