Dynamic Host Configuration Protocol

Master DHCP architecture, operation, and network configuration with interactive simulations and comprehensive technical coverage for undergraduate computer networks.

📚 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

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

67
DHCP Server
(Destination)
68
DHCP Client
(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.

1
DISCOVER
Client broadcasts to locate available DHCP servers
2
OFFER
Server responds with proposed IP address and lease terms
3
REQUEST
Client accepts offer and broadcasts acceptance
4
ACKNOWLEDGE
Server confirms assignment and finalizes lease

DHCPDISCOVER Message Details

The client broadcasts a discovery message to find DHCP servers. Since the client has no IP address yet, it uses 0.0.0.0 as source and broadcasts to 255.255.255.255.

Source IP: 0.0.0.0
Destination IP: 255.255.255.255
Source MAC: Client MAC
Destination MAC: FF:FF:FF:FF:FF:FF
Message Type: Broadcast (Layer 2 & 3)

DHCPOFFER Message Details

Server responds with an available IP address from its scope, lease duration, subnet mask, gateway, and DNS information. Multiple servers may respond if available.

Source IP: DHCP Server IP
Destination IP: 255.255.255.255
Source MAC: Server MAC
Destination MAC: Client MAC (Unicast L2)
Offered IP: Available from Scope

DHCPREQUEST Message Details

Client broadcasts acceptance of one offer (typically the first received), implicitly declining others. This broadcast ensures all servers know which offer was accepted.

Source IP: 0.0.0.0
Destination IP: 255.255.255.255
Requested IP: Selected Offer IP
Server ID: Chosen Server Identifier
Purpose: Decline other offers

DHCPACK Message Details

Server finalizes the lease, committing the IP address to the client. Client now configures its interface with the assigned parameters and can begin network communication.

Source IP: DHCP Server IP
Destination IP: 255.255.255.255
Assigned IP: Client's New IP
Lease Time: Duration in Seconds
Options: Subnet Mask, Gateway, DNS

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

T0
Lease Start
T1 (Renewal)
50% of Lease
T2 (Rebinding)
87.5% of Lease
Expiry
100% - Release
T1

Renewal Time (50%)

Client sends unicast DHCPREQUEST to original server. If ACK received, lease extended. If no response, wait until T2.

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.

T3

Lease Expiry (100%)

Client must stop using IP address and restart full DORA process. All TCP connections are terminated.

📊 Lease Time Calculator

T1 (Renewal): 12 hours (50%)
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

Network A
192.168.1.0/24
Client
Router
(Relay)
Network B
192.168.2.0/24
DHCP
Server

Relay Process Flow

  1. Client Broadcast: Client sends DHCPDISCOVER broadcast in local subnet
  2. Relay Interception: Router (relay agent) receives broadcast on client-facing interface
  3. giaddr Insertion: Relay inserts Gateway IP Address (giaddr) field with receiving interface IP
  4. Unicast Forward: Relay forwards packet as unicast to configured DHCP server IP
  5. Server Response: Server uses giaddr to determine appropriate IP scope and sends unicast reply to relay
  6. 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:

  1. Install Remote Access role with Routing service
  2. Enable LAN routing in RRAS configuration
  3. Add DHCP Relay Agent protocol under IPv4
  4. Configure interface facing clients
  5. 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?

A. UDP 68
B. UDP 67
C. TCP 80
D. UDP 53

2. At what percentage of lease time does a client first attempt to renew its IP address?

A. 50%
B. 25%
C. 75%
D. 87.5%

3. What is the purpose of the giaddr field in DHCP relay?

A. Identify the DHCP server
B. Indicate the client's subnet for proper IP allocation
C. Specify the DNS server address
D. Define the lease duration

4. Which DHCP message type is broadcast at both Layer 2 and Layer 3?

A. DHCPDISCOVER
B. DHCPOFFER
C. DHCPACK
D. All of the above

🎯 Key Takeaways