DevOps

How DHCP Works Cheatsheet

Comprehensive guide to DHCP (Dynamic Host Configuration Protocol) covering the 4-step DORA process (Discover, Offer, Request, Acknowledge), message types, lease management, server configuration, troubleshooting, and best practices for automatic IP address allocation.

#dhcp #networking #ip-address #dora #server #protocol #lease

Building a resilient DHCP design? Refresh the fundamentals on our main dashboard and track live VPS performance on the performance dashboard before rolling out changes.

When selecting infrastructure, browse the benchmark reports, stack plans side-by-side in the VPS comparison tool, and evaluate each vendor inside our provider directory.

Sign In to Download

Free account required

i

What is DHCP?

DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses and network configuration to devices on a network. It uses a 4-step process (DORA) to dynamically allocate IP addresses, eliminating the need for manual configuration.

Need to validate supporting services? Run quick checks with our network tools suite, trace packet flows with the TCP handshake cheatsheet, and revisit DNS fundamentals via the DNS reference guide to keep name resolution aligned with your DHCP scopes.

Discover
Client finds DHCP server
Offer
Server proposes IP address
Request
Client requests offered IP
Acknowledge
Server confirms allocation

DORA Process - How DHCP Works

The Four Steps (DORA)

1
Client → DHCP Server: DHCP Discover

Discovery stage: Client broadcasts a DHCP Discover message to locate available DHCP servers on the network.

Source: 0.0.0.0:68 → Destination: 255.255.255.255:67 (Broadcast)
Message Type: DHCPDISCOVER
Client MAC: AA:BB:CC:DD:EE:FF
2
DHCP Server → Client: DHCP Offer

Offer stage: DHCP servers respond with a DHCP Offer message, proposing an IP address lease along with other configuration parameters.

Message Type: DHCPOFFER
Offered IP: 192.168.1.100
Subnet Mask: 255.255.255.0
Gateway: 192.168.1.1
DNS: 8.8.8.8, 8.8.4.4
Lease Time: 86400 seconds (24 hours)
3
Client → DHCP Server: DHCP Request

Request stage: Client selects one of the offered IP addresses and sends a DHCP Request message to the chosen DHCP server, requesting the lease.

Message Type: DHCPREQUEST
Requested IP: 192.168.1.100
Server Identifier: 192.168.1.1
Client MAC: AA:BB:CC:DD:EE:FF
4
DHCP Server → Client: DHCP Acknowledgement

Acknowledge stage: The DHCP server acknowledges the client's request by sending a DHCP Acknowledge (ACK) message, confirming the allocation and providing additional configuration.

Message Type: DHCPACK
Assigned IP: 192.168.1.100
Lease Start: Now
Lease Expiration: 86400 seconds
Client can now use the network!

Network Ports Used

Server Port: UDP 67
DHCP server listens on this port
Client Port: UDP 68
DHCP client sends from this port

Key Information Provided by DHCP

  • IP Address: Unique address for the device
  • Subnet Mask: Network segmentation information
  • Default Gateway: Router IP for internet access
  • DNS Servers: Domain name resolution servers
  • Lease Time: Duration the IP address is valid
  • NTP Servers: Time synchronization (optional)
  • Domain Name: Local domain suffix (optional)

DHCP Message Types

Message Type Direction Purpose
DHCPDISCOVER Client → Server Broadcast to find available DHCP servers
DHCPOFFER Server → Client Offer IP address and configuration parameters
DHCPREQUEST Client → Server Request offered IP or renew/rebind existing lease
DHCPACK Server → Client Acknowledge and confirm IP address assignment
DHCPNAK Server → Client Deny request (IP no longer available or invalid)
DHCPDECLINE Client → Server Client declines offered IP (already in use)
DHCPRELEASE Client → Server Client voluntarily releases IP address
DHCPINFORM Client → Server Request local configuration (client has static IP)

DHCP Lease Process

Lease Timeline

T0 (0%)
Lease Begins

Client receives IP address and starts using it

T1 (50%)
Renewal Time

Client attempts to renew lease with original DHCP server (unicast DHCPREQUEST)

T2 (87.5%)
Rebinding Time

If T1 renewal fails, client broadcasts DHCPREQUEST to any DHCP server

T3 (100%)
Lease Expires

If no renewal, client must stop using IP and restart DORA process

Example: 24-Hour Lease

Lease Duration: 86400 seconds (24 hours)
T0 (Start):    0:00 - IP assigned
T1 (Renewal):  12:00 (50%) - Client tries to renew with original server
T2 (Rebind):   21:00 (87.5%) - Client broadcasts to any server
T3 (Expire):   24:00 (100%) - Lease expires, must restart DORA

Lease Renewal Process

1. At T1, client sends unicast DHCPREQUEST to original server
2. Server responds with DHCPACK (lease renewed) or DHCPNAK (must get new IP)
3. If successful, new lease period begins from T0
4. If T1 fails, wait for T2 and broadcast to any server

DHCP Server Configuration

ISC DHCP Server (Linux)

# /etc/dhcp/dhcpd.conf

# Basic configuration
default-lease-time 86400;
max-lease-time 172800;
authoritative;

# Subnet declaration
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 "example.local";
}

# Static IP reservation (by MAC address)
host printer {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 192.168.1.10;
}

dnsmasq (Lightweight Option)

# /etc/dnsmasq.conf

# Interface to listen on
interface=eth0

# DHCP range and lease time
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,24h

# Gateway
dhcp-option=3,192.168.1.1

# DNS servers
dhcp-option=6,8.8.8.8,8.8.4.4

# Static lease by MAC
dhcp-host=00:11:22:33:44:55,192.168.1.10,printer

Windows DHCP Server

# PowerShell commands

# Install DHCP Server role
Install-WindowsFeature DHCP -IncludeManagementTools

# Create DHCP scope
Add-DhcpServerv4Scope -Name "Office Network" `
    -StartRange 192.168.1.100 `
    -EndRange 192.168.1.200 `
    -SubnetMask 255.255.255.0 `
    -LeaseDuration 1.00:00:00

# Set scope options
Set-DhcpServerv4OptionValue -ScopeId 192.168.1.0 `
    -Router 192.168.1.1 `
    -DnsServer 8.8.8.8,8.8.4.4

Common DHCP Options

Option Number Purpose
Subnet Mask 1 Network subnet mask
Router/Gateway 3 Default gateway IP
DNS Server 6 DNS server addresses
Domain Name 15 DNS domain suffix
NTP Server 42 Time synchronization
Lease Time 51 IP address lease duration

Troubleshooting DHCP Issues

Common Issues

No IP Address (169.254.x.x / APIPA)

Symptoms: Client gets 169.254.x.x address (APIPA/link-local)

Causes: No DHCP server reachable, network cable unplugged, DHCP server down

# Linux: Check DHCP client status
$ sudo systemctl status dhclient
$ sudo journalctl -u dhclient

# Windows: Release and renew
C:\> ipconfig /release
C:\> ipconfig /renew
IP Address Conflicts

Symptoms: Intermittent connectivity, "IP address conflict" error

Causes: Static IP overlaps with DHCP range, rogue DHCP server

# Linux: Check for duplicate IPs
$ sudo arping -D -I eth0 192.168.1.100

# Scan for rogue DHCP servers
$ sudo nmap --script broadcast-dhcp-discover
DHCP Pool Exhausted

Symptoms: New devices can't get IP, existing leases work fine

Causes: Too many devices, lease time too long, zombie leases

# Check active leases (ISC DHCP)
$ sudo dhcp-lease-list
$ cat /var/lib/dhcp/dhcpd.leases

# dnsmasq
$ cat /var/lib/misc/dnsmasq.leases
Slow DHCP Response

Symptoms: Long delay before getting IP address

Causes: Server overloaded, network latency, spanning tree delays

# Capture DHCP traffic
$ sudo tcpdump -i eth0 -n port 67 or port 68

# Monitor server performance
$ sudo systemctl status isc-dhcp-server
$ top -p $(pidof dhcpd)

DHCP Client Commands

# Linux - Release and renew
$ sudo dhclient -r eth0        # Release
$ sudo dhclient eth0           # Renew

# Alternative: NetworkManager
$ sudo nmcli con down "Wired connection 1"
$ sudo nmcli con up "Wired connection 1"

# Windows
C:\> ipconfig /release
C:\> ipconfig /renew
C:\> ipconfig /all             # View DHCP info

# macOS
$ sudo ipconfig set en0 DHCP

Packet Capture Analysis

# Capture DHCP traffic
$ sudo tcpdump -i any -n -vv port 67 or port 68

# With Wireshark filter
bootp

# Expected output for successful DORA:
1. DHCPDISCOVER (broadcast)
2. DHCPOFFER (from server)
3. DHCPREQUEST (broadcast)
4. DHCPACK (from server)

DHCP Best Practices

Use DHCP Reservations for Servers
Reserve IP addresses by MAC for servers, printers, and critical infrastructure while keeping management centralized
Implement DHCP Redundancy
Use 80/20 rule: Primary server handles 80% of pool, secondary handles 20%. Or use DHCP failover for high availability
Set Appropriate Lease Times
Office Networks: 8-24 hours | Guest WiFi: 1-4 hours | Data Centers: 7-30 days
Monitor DHCP Pool Usage
Keep pool utilization below 80%. Alert when threshold is reached to prevent exhaustion
Secure DHCP with DHCP Snooping
Enable DHCP snooping on switches to prevent rogue DHCP servers and man-in-the-middle attacks
Document IP Address Scheme
Maintain clear documentation of DHCP ranges, static reservations, and excluded addresses for troubleshooting
Separate Subnets by Function
Use VLANs and separate DHCP scopes for different networks (user, IoT, guest) for better security and management
Regular Backup and Testing
Backup DHCP configuration regularly and test failover mechanisms to ensure business continuity

Optimize Your Network Infrastructure

Understanding DHCP is essential for efficient network management. Check our VPS benchmarks to find providers with reliable networking performance and enterprise-grade infrastructure for your DHCP servers.

Looking for our methodology? Meet the team on the About page, or tell us about your network rollout via the contact form. Before collecting user data, review the safeguards outlined in our privacy policy.

Continue sharpening your skills with companion guides such as the Linux networking commands cheatsheet and our cloud platform models reference, then monitor infrastructure benchmarks on the performance dashboard as you scale DHCP services across providers.