TCP/IP Protocol: Dynamic Host Control Protocol (DHCP)


Jarret W. Buse

TCP/IP Protocol: Dynamic Host Control Protocol (DHCP)

There are three things we need to look at with the Dynamic Host Control Protocol (DHCP) in this article for you to understand how DHCP works.​
  1. DHCP Server​
  2. DHCP Client​
  3. The DHCP Protocol​
The DHCP Server is the system on a network which manages and assigns IP Addresses to the DHCP Clients.

Let’s take a Linux system and set up a DHCP Server. We perform the following steps:​
  1. Install dhcp3-server following any prompts required​
  2. When asked for the connection to install the DHCP Server on, select your appropriate network port (such as eth0).​
  3. Configure the DHCP Server​
  4. Edit the DHCP configuration as root (sudo gedit /etc/dhcp3/dhcpd.conf)​
The code in the configuration file is as follows:

subnet netmask {
  option domain-name “”;
  option domain-name-servers,;
  option broadcast-address;
  option routers;
  option subnet-mask;

The first line: subnet netmask shows that the subnet is Since the Host ID is 0.0.0, this represents a subnet and not an actual address. The netmask for the subnet is the default for a Class A address of

NOTE: For more information on netmasking, see Netmasking Transmission Control Protocol/Internet Protocol (TCP/IP).

The second line of the configuration file: range shows the available addresses to assign. These are the actual addresses that the DHCP Server will assign to the DHCP Clients. Be sure that the range of addresses is available and also part of the subnet listed in line 1. Do not attempt to assign addresses that are already statically used by any systems or devices.

The third line lists the domain name: option domain-name “”. The Domain Name is used within the network to find other systems on the Local Area Network (LAN) just as they would be on the Internet. Let’s assume we have a system with a name of ‘backup’. On the network the system would be accessed as ‘’.

The fourth line sets the DNS Servers which will be auto-assigned to the DHCP Clients: option domain-name-servers, Be sure that the DNS server IP Addresses are valid and do not use a ‘friendly name’.

The fifth line lists the broadcast address for the subnet: option broadcast-address Here, the Network ID must be the same as the subnet (line 1) and the Host ID are all ones in binary.

Line six lists the gateways or where the frames are sent if they are not destined for the local network. In the example listing: option routers the gateway address is

The last line lists the subnet mask. In this example we use the default Class A netmask as shown: option subnet-mask If we use CIDR, it would be different.

Once any of these options are changed, they can be in effect after the service is restarted. In the above example 100 DHCP clients can be dynamically configured. If a gateway address should change it would be easier to change the value on the DHCP server than to have to go to 100 client systems and change the value manually.

At this point, the DHCP server should be restarted or at least restart the DHCP Service.

Now, we should cover the DHCP Client. The DHCP Clients are those clients which will be dynamically configured by the DHCP Client.

The configuration is shown in Figure 1.​

TCPIP Protocol DHCP - Figure 1.JPG


To enable the system for DHCP, the Method would be changed to ‘DHCP’. After this, the client would receive an IP Address and all settings from the DHCP Server.

Once enabled for DHCP, the client can request an IP Address lease from the DHCP Server. There are four basic steps to obtain a lease:
  1. Request
  2. Offer
  3. Selection
  4. Acknowledgement
The Request is made from the DHCP Client when it starts up and requires an IP Address. Since it has no address, it broadcasts a generic request to an address of and a destination of The name of the system is included in the information of the broadcast. If no response is received, the system will repeat the broadcast at specified intervals until a response is received. If no response is ever made, then the system will not be able to use TCP/IP.

After the DHCP Server receives the Request, it can check its database to determine if there are any available addresses. If an address is available, the server makes an Offer. The frame contains the IP Address and other information that the DHCP Server is configured to set on the DHCP Client. Other information included is the DHCP Server’s IP Address and Netmask to allow the DHCP Client to contact the server again. Another item set in the Offer is the lease time. The DHCP Server will make a temporary reservation for the address offered so it is not offered simultaneously to another DHCP Client.

NOTE: The lease time allows a server to reuse IP Addresses in case a system is off for too long, the range of addresses is not depleted. In actuality, most DHCP Clients start a renewal for the lease once half the lease time has expired. A problem can occur if a DHCP goes offline and all clients need time to renew the lease.

The first offer that a DHCP Client receives from a DHCP Server is accepted or selected. On a network with multiple DHCP Servers (mainly for redundancy with each server issuing a different range of addresses), the first is accepted and the rest are rejected. Another broadcast is made to select the offer from a specific DHCP Server.

Finally, the DHCP Server receives the broadcast of the selected offer. If everything is correct at this point, the DHCP Server sends a DHCP Acknowledgment to the DHCP Client. The DHCP Client at this point is set to initialize TCP/IP with the information sent from the DHCP Server. If the DHCP Server has found something wrong, a DHCP negative Acknowledgement is sent to the DHCP Client and it restarts the DHCP Lease process all over.

As you can probably tell, IP Addresses are extremely important to setting up TCP/IP. To prevent mistakes from occurring, such as a duplicate IP Address, it is best to use a DHCP Server.

NOTE: If two systems have the same IP Address on the same network, the second system cannot initialize TCP/IP. For this reason, when multiple DHCP Servers are used, the Address Range cannot overlap.


  • slide.jpg
    56.3 KB · Views: 100,643
$100 Digital Ocean Credit
Get a free VM to test out Linux! Hosting Donations
Consider making a donation

Members online