How DHCP Works (Dynamic Host Configuration Protocol)
DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to automatically assign IP addresses and essential configuration parameters to devices on a network.
It operates on a client-server model, where the DHCP server maintains a pool of IP addresses and dynamically leases them to clients (like laptops, phones, printers).
DHCP Process – DORA
The DHCP workflow follows a four-step sequence known as DORA:
- Discover – Client → Server
- Offer – Server → Client
- Request – Client → Server
- Acknowledge – Server → Client
1. DHCP Discover
When a device joins the network and needs an IP, it sends a DHCP Discover broadcast to find available DHCP servers.
- Source IP: 0.0.0.0 (no IP yet)
- Destination: 255.255.255.255 (broadcast)
2. DHCP Offer
DHCP servers respond with a DHCP Offer containing:
- Proposed IP address
- Subnet mask
- Default gateway
- DNS server(s)
- Lease duration
3. DHCP Request
The client selects one Offer (if multiple) and broadcasts a DHCP Request to formally request the offered IP. Broadcasting ensures all servers know which offer was accepted.
4. DHCP Acknowledge
The selected server responds with a DHCP ACK to finalize the lease. If the server declines, it sends a DHCP NAK and the client must restart the process.
DHCP Lease Renewal Process
DHCP leases are temporary and clients must renew them to continue using the IP:
- T1 Timer (50%): Client sends a unicast DHCP Request to the original server to renew the lease.
- T2 Timer (87.5%): If no response, client broadcasts the Request to any available DHCP server.
- Expiration: If no server responds, the lease expires and the client starts the DORA process again.
DHCP Relay Agent (ip helper-address)
In large networks, clients and DHCP servers may be in different subnets. Since broadcast messages don’t cross routers, a DHCP Relay Agent is used to forward these messages.
On an interface:
ip helper-address 192.168.20.10
This forwards client DHCP Discover packets to the DHCP server at 192.168.20.10.
Benefits of DHCP
- ✅ Eliminates manual IP configuration
- ✅ Prevents IP conflicts
- ✅ Simplifies DNS, gateway, and subnet changes
- ✅ Supports dynamic and reserved/static assignments
Real-Life Example – Home Network
- Your laptop joins a Wi-Fi network → Sends DHCP Discover
- Home router (DHCP server) replies with Offer (e.g., 192.168.1.10)
- Laptop sends DHCP Request to accept
- Router replies with DHCP ACK → IP assigned
Conclusion
DHCP significantly simplifies IP address management by dynamically allocating IPs and ensuring efficient, error-free configuration. The DORA process ensures a reliable handshake, while lease renewals maintain long-term connectivity.