DHCP stands for Dynamic Host Configuration Protocol. As its name suggests DHCP is used to provide configuration like Ip Address, Network Mask, DNS, Proxy, Bootp, Default Gateway, etc. to the host. But the most know and popular usage are distributing IP addresses. There is a broad range of DHCP usage scenarios. In this tutorial, we will look at the IP address distribution of DHCP with an example.
DHCP Lease Phases
DHCP IP address assignment is done in 4 steps where all steps will be examined below. DHCP uses UDP packets which means connectionless architecture. DHCP works as a client-server architecture. The client initiate the process. Some times clients may be residing in the different networks so to transmit DHCP packet a DHCP Helper or DHCP Relay needed in the client network.
DHCP Lab Environment
We will use Gns3 as lab environment. There will be also a DHCP server which is Pfsense and a DHCP client Windows Server 2012. We will enable DHCP service of Pfsense and than capture the DHCP traffic with Wireshark.
Enable DHCP Service
DHCP service configuration screen can be accessed like below.
Services -> DHCP Server
Click to the
Enable DHCP server on LAN interface.And then set IP address range. In this example we will use
10.0.0.254. To start DHCP service with specified configuration click
Save button on the bottom of the page.
DHCP Discovery Step and Package
Following screenshot shows everything about discovery packet sent from client. Client simply send broadcast packet to get an offer from DHCP server currently serves for this network.
DHCP Offer Step and Package
DHCP server listening to the network of the currently requested client and provides an offer to this client. Offered IP address is 10.0.0.128 and lease time is 2 hours. The lease time is to set expire time for a given IP address. After the lease time is timed out client will re-request the same IP address automatically.
DHCP Request Step and Package
The client will get the offer and in most situations, the client will accept offered IP address and network configuration. As we see the client also sends its hostname with hostname Option 12.
DHCP Acknowledge Step and Package
After the server gets the response from the client it will assign the offered IP address to this client and allocate this IP. This IP will not be offered to new clients if it is not freed.