DHCP Process Explained [Step by Step]

DHCP Process Explained [Step by Step]

What is DHCP

  • DHCP provides a mechanism through which computers that use TCP/IP can obtain protocol configuration parameters automatically through the network.
  • DHCP is based on a client-server paradigm, in which the DHCP client, for example, a desktop computer, contacts a DHCP server for configuration parameters. The DHCP server is typically centrally located and operated by the network administrator.
  • DHCP clients initially have no configured IP address and must therefore send a broadcast request to obtain an IP address from a DHCP server.


DHCP Workflow

The DHCP steps Messages are:

  • DHCP DISCOVER
  • DHCP OFFER
  • DHCP REQUEST
  • DHCP ACK


A nice way to remember the process is “DORA”


We will perform a simple lab to illustrate to DHCP Steps:

I have used 2 routers, one as a client and the other as DHCP server, below is the basic configuration for DHCP:

DHCP_Server1(config)#int e0/0
DHCP_Server1(config-if)#ip address 192.168.10.254 255.255.255.0
DHCP_Server1(config-if)#no sh
DHCP_Server1(config-if)#exit

DHCP_Server1(config)#ip dhcp pool VLAN_10
DHCP_Server1(dhcp-config)#network 192.168.10.0 255.255.255.0
DHCP_Server1(dhcp-config)#default-router 192.168.10.254
DHCP_Server1(dhcp-config)#exit

DHCP_Server1(config)#ip dhcp excluded-address  192.168.10.254
lient_Vlan10(config)#int e0/0
Client_Vlan10(config-if)#ip address dhcp


I- DHCP DISCOVER

When a client boots up for the first time, and transmits a DHCPDISCOVER message on its local physical subnet over User Datagram Protocol (UDP) port 67. Since the client has no way to know the subnet to which it belongs, the DHCPDISCOVER is an all subnets broadcast (destination IP address of 255.255.255.255), with a source IP address of 0.0.0.0. The source IP address is 0.0.0.0 since the client does not have a configured IP address.


The following Wireshark capture illustrates the DHCP Discover packet sent from the client:


If a DHCP server exists on this local subnet and is configured and operates correctly, the DHCP server hears the broadcast and responds with a DHCPOFFER message.


II- DHCP OFFER

A DHCP server that receives a DHCPDISCOVER message can respond with a DHCPOFFER message on UDP port 68 (BootP client). The client receives the DHCPOFFER and moves into the Selecting state.

 This DHCPOFFER message contains initial configuration information for the client. For example, the DHCP server fills in the yiaddr field of the DHCPOFFER message with the requested IP address. The subnet mask and default gateway are specified in the options field, subnet mask and router options, respectively.

 This DHCPOFFER message contains initial configuration information for the client. For example, the DHCP server fills in the yiaddr field of the DHCPOFFER message with the requested IP address. The subnet mask and default gateway are specified in the options field, subnet mask and router options, respectively.

Other common options in the DHCPOFFER message include IP Address lease time, renewal time, domain name server:


The DHCP server sends the DHCPOFFER to the broadcast address but includes the client hardware address in the chaddr field of the offer, so the client knows that it is the intended destination.


III- DHCP REQUEST

After the client receives a DHCPOFFER, it responds with a DHCPREQUEST message, and indicates its intent to accept the parameters in the DHCPOFFER, and moves into the Requesting state.

The client identifies the selected server after it populates the Server Identifier option field with the DHCP server IP address. The DHCPREQUEST is also a broadcast, so all DHCP servers that sent a DHCPOFFER see the DHCPREQUEST, and each knows whether its DHCPOFFER was accepted or declined. 

Any additional configuration options that the client requires are included in the options field of the DHCPREQUEST message. Even though the client has been offered an IP address, it sends the DHCPREQUEST message with a source IP address of 0.0.0.0. At this time, the client has not yet received verification that it is clear to use the IP address.


IV- DHCP REQUEST

After the DHCP server receives the DHCPREQUEST, it acknowledges the request with a DHCPACK message, and then completes the initialization process. The DHCPACK message has a source IP address of the DHCP server, and the destination address is once again a broadcast and contains all the parameters that the client requested in the DHCPREQUEST message. When the client receives the DHCPACK, it enters into the Bound state, and is now free to use the IP address to communicate on the network.


Meanwhile, the DHCP server stores the lease in its database and uniquely identifies it with the client identifier or chaddr, and the associated IP address. Both the client and server use this combination of identifiers to refer to the lease. The client identifier is the MAC address of the device plus the media type.

Before the DHCP client begins to use the new address, the DHCP client must calculate the time parameters associated with a leased address, which are Lease Time (LT), Renewal Time (T1), and Rebind Time (T2). The typical default LT is 72 hours. You can use shorter lease times to conserve addresses if needed.


One thing to notice is that the DHCP Offer contains the default router information (option 3), as a result, the client has installed a default route via the IP mentioned in the Route option:

Client_Vlan10#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.10.254 to network 0.0.0.0

C    192.168.10.0/24 is directly connected, Ethernet0/0
S*   0.0.0.0/0 [254/0] via 192.168.10.254

DHCPNAK

If the selected server is unable to satisfy the DHCPREQUEST message, the DHCP server responds with a DHCPNAK message.

Bilel Ameur

Enthusiastic Network Engineer specializing in Cisco ACI, passionate about solving challenges. A lifelong learner who loves gaining and sharing knowledge. Profile: https://www.linkedin.com/in/bilel-ameur-71116b2b5
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x