No matter the type of host, any host that uses IPv4 needs four IPv4 settings to work properly:
- IP address
- Subnet mask
- Default routers
- 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 192.168.1.0 255.255.255.0 // specify network
(dhcp-config)#default-router 192.168.1.1 // specify default gateway
(dhcp-config)#dns-server 192.168.1.1 // specify DNS server
(dhcp-config)#lease 1 // specify lease for one day
(config)#ip dhcp excluded-address 192.168.1.1 // 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:
- 0.0.0.0: An address reserved for use as a source IPv4 address for hosts that do not yet have an IP address.
- 255.255.255.255: The local broadcast IP address. Packets sent to this destination address are broadcast on the local data link, but routers do not forward them.

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 255.255.255.255
- 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


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

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
lease DAYS HOURS MINUTES
domain-name NAME
next-server IP_ADDRESS


IOS DHCP server verification:


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.