📚 Introduction to DHCP
DHCP (Dynamic Host Configuration Protocol) is an application layer protocol that automates the assignment of IP addresses and network configuration parameters to devices joining a network. Operating on UDP, DHCP eliminates manual IP configuration, reducing administrative overhead and configuration errors.
Why DHCP is Essential
- Eliminates manual IP address assignment errors
- Centralizes IP address management
- Supports mobile devices moving between networks
- Efficiently manages limited IPv4 address space
- Provides automatic DNS, gateway, and subnet mask configuration
Key DHCP Components
DHCP Client
Any network device requesting IP configuration. Initially has no IP (0.0.0.0) and uses broadcast to discover servers.
DHCP Server
Maintains a pool (scope) of available IP addresses and configuration parameters. Listens on UDP port 67.
IP Address Pool (Scope)
The range of IP addresses available for assignment, plus excluded addresses and reservations.
Lease
Temporary assignment of an IP address to a client for a specific duration, after which it must be renewed or released.
DHCP Port Allocation
(Destination)
(Source)
DHCP uses UDP services with specific port assignments for client-server communication.
🔄 The DORA Process
DHCP operates through a four-step message exchange known as DORA (Discover, Offer, Request, Acknowledge). This process ensures reliable IP address assignment while handling multiple servers and preventing conflicts.
Message Type Summary
| Message | Source | Destination | Layer 2 | Layer 3 |
|---|---|---|---|---|
| DHCPDISCOVER | 0.0.0.0:68 | 255.255.255.255:67 | Broadcast | Broadcast |
| DHCPOFFER | Server IP:67 | 255.255.255.255:68 | Unicast | Broadcast |
| DHCPREQUEST | 0.0.0.0:68 | 255.255.255.255:67 | Unicast | Broadcast |
| DHCPACK | Server IP:67 | 255.255.255.255:68 | Unicast | Broadcast |
⏱️ Lease Management & Renewal
DHCP leases are temporary assignments that must be renewed periodically. The lease mechanism ensures efficient IP address utilization and allows for network changes.
Lease Renewal Timeline
Renewal Time (50%)
Client sends unicast DHCPREQUEST to original server. If ACK received, lease extended. If no response, wait until T2.
Rebinding Time (87.5%)
Client broadcasts DHCPREQUEST to any available server. If new server responds with ACK, lease continues. If NAK or no response, lease expires.
Lease Expiry (100%)
Client must stop using IP address and restart full DORA process. All TCP connections are terminated.
📊 Lease Time Calculator
T2 (Rebinding): 21 hours (87.5%)
Recommended for: Stable wired networks
Lease Duration Recommendations
| Environment | Recommended Lease | Rationale |
|---|---|---|
| Wired Corporate Network | 8-24 hours | Stable devices, reduce DHCP traffic |
| Wireless/Guest Network | 2-4 hours | High mobility, quick turnover |
| Public WiFi/Hotels | 30-60 minutes | Transient users, security |
| Data Center | Infinite/Reservation | Servers need permanent IPs |
🌐 DHCP Relay Agent
Since routers do not forward broadcast packets by default, DHCP clients in different subnets from the DHCP server cannot reach it directly. The DHCP Relay Agent solves this by forwarding DHCP messages between subnets.
Relay Agent Operation
192.168.1.0/24
(Relay)
192.168.2.0/24
Server
Relay Process Flow
- Client Broadcast: Client sends DHCPDISCOVER broadcast in local subnet
- Relay Interception: Router (relay agent) receives broadcast on client-facing interface
- giaddr Insertion: Relay inserts Gateway IP Address (giaddr) field with receiving interface IP
- Unicast Forward: Relay forwards packet as unicast to configured DHCP server IP
- Server Response: Server uses giaddr to determine appropriate IP scope and sends unicast reply to relay
- Broadcast Delivery: Relay broadcasts reply on client interface (client still has no IP)
Key Configuration: ip helper-address
The ip helper-address command configures a router interface to forward DHCP broadcasts to a specific server:
! Cisco IOS Configuration Example
interface GigabitEthernet0/1
description Client Network
ip address 192.168.1.1 255.255.255.0
ip helper-address 192.168.2.2 ! DHCP Server IP
Important Note
The ip helper-address command is applied to the client-facing interface (the interface receiving DHCP broadcasts), not the server-facing interface. This is a common configuration error.
⚙️ DHCP Configuration Examples
Cisco IOS DHCP Server Configuration
! Enable DHCP service (if disabled)
R1(config)# service dhcp
! Create DHCP Pool
R1(config)# ip dhcp pool STUDENT-LAN
R1(dhcp-config)# network 192.168.1.0 255.255.255.0
R1(dhcp-config)# default-router 192.168.1.1
R1(dhcp-config)# dns-server 8.8.8.8 8.8.4.4
R1(dhcp-config)# domain-name university.edu
R1(dhcp-config)# lease 8
! Exclude static/reserved addresses
R1(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
R1(config)# ip dhcp excluded-address 192.168.1.254
! Verification commands
R1# show ip dhcp pool
R1# show ip dhcp binding
R1# show ip dhcp server statistics
Windows Server DHCP Relay Configuration
According to Microsoft documentation [^13^], configure DHCP Relay Agent through Routing and Remote Access:
- Install Remote Access role with Routing service
- Enable LAN routing in RRAS configuration
- Add DHCP Relay Agent protocol under IPv4
- Configure interface facing clients
- Add DHCP server IP address in relay properties
Linux (ISC DHCP) Configuration
# /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option domain-name "university.edu";
default-lease-time 28800; # 8 hours
max-lease-time 43200; # 12 hours
}
# Static reservation by MAC address
host student-pc-01 {
hardware ethernet 00:1A:2B:3C:4D:5E;
fixed-address 192.168.1.50;
}
Common DHCP Options
| Option Code | Name | Description |
|---|---|---|
| 1 | Subnet Mask | Specifies the subnet mask for the network |
| 3 | Router | Default gateway IP address(es) |
| 6 | Domain Name Server | DNS server IP addresses |
| 15 | Domain Name | DNS domain suffix for the client |
| 51 | IP Address Lease Time | Duration of IP assignment in seconds |
| 53 | DHCP Message Type | Discover/Offer/Request/ACK/etc. |
| 54 | Server Identifier | IP address of the DHCP server |
🔧 Troubleshooting Common Issues
IP Conflict
Symptom: "IP address already in use"
Cause: Static IP in DHCP range or rogue DHCP server
Fix: Expand excluded-address range, enable DHCP snooping
Lease Exhaustion
Symptom: Clients fail to obtain IP
Cause: Scope too small or lease time too long
Fix: Expand scope or reduce lease duration
Relay Failure
Symptom: No DHCP across subnets
Cause: Missing ip helper-address or firewall blocking UDP 67/68
Fix: Verify helper-address on client interface, check ACLs
Verification Commands
| Platform | Command | Purpose |
|---|---|---|
| Cisco IOS | show ip dhcp pool |
View pool utilization and configuration |
show ip dhcp binding |
Display active leases (MAC to IP mappings) | |
show ip dhcp relay |
Verify relay agent configuration | |
| Windows | ipconfig /all |
View DHCP assigned parameters |
| Linux | dhclient -v eth0 |
Verbose DHCP client operation |
| Wireshark | bootp or dhcp |
Filter DHCP traffic for analysis |
📝 Knowledge Check
1. Which port does the DHCP server use to listen for client requests?
2. At what percentage of lease time does a client first attempt to renew its IP address?
3. What is the purpose of the giaddr field in DHCP relay?
4. Which DHCP message type is broadcast at both Layer 2 and Layer 3?
🎯 Key Takeaways
- DHCP automates IP configuration using the DORA process (Discover, Offer, Request, Acknowledge)
- Clients initially use 0.0.0.0 as source IP and broadcast to 255.255.255.255
- Leases must be renewed at 50% (T1) and rebinding attempted at 87.5% (T2) of lease time
- DHCP Relay Agents (ip helper-address) enable DHCP across subnet boundaries
- UDP ports 67 (server) and 68 (client) are used for all DHCP communications
- Proper scope configuration requires balancing lease time with network mobility needs