DHCP and IP Networking on Hosts

No matter the type of host, any host that uses IPv4 needs four IPv4 settings to work properly: 

  1. IP address  
  2. Subnet mask  
  3. Default routers  
  4. DNS server IP addresses 

In particular, this chapter begins by discussing how a host can dynamically learn these four settings using the Dynamic Host Configuration Protocol (DHCP).  

#show ip dhcp binding // check if leased IP addresses are present 
(config)#ip dhcp pool <NAME> // create pool 
(dhcp-config)#network // specify network 
(dhcp-config)#default-router // specify default gateway  
(dhcp-config)#dns-server // specify DNS server 
(dhcp-config)#lease 1 // specify lease for one day 
(config)#ip dhcp excluded-address // exclude router's IP address 
#show ip dhcp pool // see pools 

Dynamic Host Configuration Protocol (DHCP) is one of the most commonly used protocols in a TCP/IP network. The vast majority of hosts in a TCP/IP network are user devices, and the vast majority of user devices learn their IPv4 settings using DHCP. The configuration of host IP settings sits in a DHCP server, with each client learning these settings using DHCP messages 

The DHCP process to lease an IP address uses the following four messages between the client and server.  

  • Discover: Sent by the DHCP client to find a willing DHCP server  
  • Offer: Sent by a DHCP server to offer to lease to that client a specific IP address (and inform the client of its other parameters)  
  • Request: Sent by the DHCP client to ask the server to lease the IPv4 address listed in the Offer message.
  • Acknowledgment: Sent by the DHCP server to assign the address, and to list the mask, default router, and DNS server IP addresses 

DHCP clients, however, have a somewhat unique problem: they do not have an IP address yet, but they need to send IP packets.  To make that work, DHCP messages make use of two special IPv4 addresses that allow a host that has no IP address to still be able to send and receive messages on the local subnet:  

  • An address reserved for use as a source IPv4 address for hosts that do not yet have an IP address.  
  • The local broadcast IP address. Packets sent to this destination address are broadcast on the local data link, but routers do not forward them. 
DHCP Server 
Figure 20-1 
DHCP Discover and Offer

Image explaining process of getting DHCP lease IP address on local subnet.  
What happens when we want to have central DHCP server outside local subnets? 

Using DHCP for remote subnets with DHCP relay: 

Network engineers have design choice with DHCP: 

  • Should I put DHCP server in every LAN subnet? 
  • Should I put one centralized DHCP server for all subnets? 

Centralized DHCP server approach has advantages. In fact, some Cisco design documents suggest centralized design as best practice because we have full control over DHCP server through entire network and DHCP can be configured from only one place. Somehow, those Discover packets need to flow not only inside that subnet, but on the other side of the network (if centralized DHCP server is configured). To do that, routers connected to the remote LAN subnets need interface subcommand: ip helper-address server-ip 

This command tells the router to do following things for messages coming in the interface from DHCP client (broadcast addresses): 

  • Watch for incoming DHCP messages with destination IP 
  • Change that packet’s source IP address to the router’s incoming interface IP address 
  • Change that packet’s destination IP address to the address of DHCP server 
  • Route the packet to the DHCP server 

This feature by which router relays DHCP messages by changing the IP addresses in the packet header is called DHCP relay 

ip helper-address 
From O.O.O.O 
Figure 20-2 IP Helper Address Effect 
DHCP Server 
DHCP Server 
Figure 20-3 IP Helper Address for the Offer Message Returned from the DHCP Server

Information stored at the DHCP server: 

DHCP server is actually DHCP server software sitting on old PC or some server machine, it does not matter. DHCP server needs good configuration to answer all DHCP client requests and supply them with IP addresses . What DHCP server needs to know to support DHCP clients: 

  • Network/Subnet ID and mask: DHCP server uses this information to know all addresses in subnet 
  • Reserved addresses: Server needs to know which addresses are not for lease. This allows admin to reserve static IP addresses. For example, most routers and switches have static addresses. 
  • Default router: IP of the router on that network/subnet 
  • DNS IP address: List of DNS server IP addresses 
Subnet = 
Static Reserve: 
Router = 
DNS = 
172.16 1. 
. 0/24 
.1 - .50 
Subnet = 
Static Reserve: 
Router = 
DNS = 
Figure 20-4 
Preconfiguration on a DHCP Server

Server also can set time limit for leasing an IP address, usually number of days and then client asks to renew the lease. If the client does not renew lease, server can reclaim the address and put it back in the pool. Server configuration decides maximum time for the lease. 

DHCP uses three allocation modes in the configuration: 

  • Dynamic allocation:  
  • Automatic allocation: sets the DHCP lease time to infinite. Once the server chooses the address, it remains like that. 
  • Static allocation: uses IP address based on client’s MAC address. That specific client is the only client that uses that IP address. 

DHCP server configuration on routers: 

Cisco routers can be configured to be DHCP server. Configuring router to act as DHCP server uses new configuration method, one per subnet, called DHCP pool. 

  • ip dhcp excluded-address IP-ADDRESS IP-ADDRESS: – list addresses that should be excluded (not leased by DHCP) 
  • ip dhcp pool NAME – create DHCP pool for subnet and navigate to DHCP pool sub mode 
  • network subnet-ID or network subnet-ID prefix-length 
  • default-router IP_ADDRESS_1 IP_ADDRESS_2 
  • dns-server IP_ADDRESS_1 IP_ADDRESS_2 
  • domain-name NAME 
  • next-server IP_ADDRESS 
Pool subnet-left 
Pool subnet-right 
Figure 20-5 
Lease Time= O Days 23 Hours 59 Minutes 
Lease Time= I Days 2 Hours 3 Minutes 
UCM Server 
DHCP Server Configuration Pseudocode
Example 20-1 R2 as a DHCP Server Per the Concepts in Figure 20-5 
ip dhcp excluded—address 172.16 .1.1 
ip dhcp excluded-address 
ip dhcp pool subnet—le 
lease 0 23 59 
domain-name example . com 
ip dhcp pool subnet —right 
network /24 
default-router 172. 
16.2. 1 
next-server 172.16.2 5

IOS DHCP server verification: 

Example 20-2 Verifying Current Operation of a Router-Based DHCP Server 
show ip dhcp binding 
Bindings from all pools not associated with VRF: 
0063 . 6973 . 636f .2d30. 
0063 . 6973 . 636f .2d30. 
3230.302e.3232.3232 . 
IP address 
Hardware address/ 
302f .30 
Lease expiration 
Oct 12 2012 02:56 AM 
Oct 12 2012 04:59 AM 
Aut i c 
2e32 . 3232 .322d.4769. 
show ip dhcp pool subnet-right 
pool subnet —right 
Utilization mark (high/low) 
Subnet size (first/next) 
Total addresses 
Leased addresses 
Pending event 
100 / o 
: 0/0 
. 254 
1 subnet is currently in the pool 
Current index 
172.16. 2.102 
IP address range 
172.16. 2.1 
Leased addresses 

DHCP relay agent configuration mistakes and symptoms: 

One configuration mistake that prevents DHCP client from leasing IP address is misconfiguration of ip helper-address interface subcommand on router acting as DHCP relay agent. 

Leave a Reply