How DHCP Works – Dynamic Host Configuration Protocol
1. What Is DHCP?
DHCP (Dynamic Host Configuration Protocol) is an application-layer protocol defined in RFC 2131 that automatically assigns IP addresses and network configuration parameters to devices the moment they connect to a network. Without DHCP, every device would require manual IP configuration — a practical impossibility at scale.
DHCP operates on a client-server model over UDP — the server listens on port 67, the client sends from port 68. The server maintains a pool of available IP addresses and leases them to clients for a configurable period of time.
A single DHCP exchange delivers everything a client needs to communicate on the network:
| Parameter | DHCP Option | Purpose | Example |
|---|---|---|---|
| IP Address | yiaddr field | Unique Layer 3 identity on the network | 192.168.1.15 |
| Subnet Mask | Option 1 | Defines local vs. remote destinations | 255.255.255.0 |
| Default Gateway | Option 3 | Router IP for off-subnet traffic | 192.168.1.1 |
| DNS Server(s) | Option 6 | Name resolution for hostnames | 8.8.8.8, 8.8.4.4 |
| Lease Time | Option 51 | How long the IP assignment is valid | 86400 seconds (1 day) |
| Domain Name | Option 15 | DNS search domain for short hostnames | company.local |
| NTP Server | Option 42 | Time synchronisation server | 10.0.0.123 |
| TFTP Server / Boot file | Option 66/67 | PXE boot server for diskless devices | 10.0.0.69 / pxelinux.0 |
Related pages: DHCP Overview | DHCP Snooping | How DNS Works | NTP Synchronisation | MAC Addresses | VLANs | Common Port Numbers | DHCP Server Configuration Lab | DHCP Relay Agent Lab | DHCP Snooping & DAI Lab | Troubleshooting DHCP Clients Lab
2. The DORA Process — Four Messages, One IP Address
Every DHCP IP lease begins with a four-message exchange known as DORA: Discover → Offer → Request → Acknowledge.
Client DHCP Server
│ │
│──── DHCP DISCOVER (broadcast) ────────────────────▶│
│ Src: 0.0.0.0:68 Dst: 255.255.255.255:67 │
│ "I need an IP address — is anyone out there?" │
│ │
│◀─── DHCP OFFER (broadcast or unicast) ─────────────│
│ "I can offer you 192.168.1.15/24 │
│ Gateway: 192.168.1.1 DNS: 8.8.8.8 │
│ Lease: 86400 seconds" │
│ │
│──── DHCP REQUEST (broadcast) ─────────────────────▶│
│ Src: 0.0.0.0:68 Dst: 255.255.255.255:67 │
│ "I accept 192.168.1.15 from server 192.168.1.1 │
│ (broadcast so ALL servers know I chose this)" │
│ │
│◀─── DHCP ACK (broadcast or unicast) ───────────────│
│ "Confirmed — 192.168.1.15 is yours │
│ Lease expires in 86400 seconds" │
│ │
Client configures:
IP: 192.168.1.15/24 GW: 192.168.1.1 DNS: 8.8.8.8
3. DHCP Discover — Message 1
The DHCP Discover is the first message sent by a client that has no IP address. It is broadcast to the entire local network segment to locate any available DHCP server.
| Field | Value | Why |
|---|---|---|
| Source IP | 0.0.0.0 |
Client has no IP yet — cannot use any real address |
| Destination IP | 255.255.255.255 |
Broadcast — sent to all devices on the local segment |
| Source Port | 68 (DHCP client) |
DHCP client always uses UDP port 68 |
| Destination Port | 67 (DHCP server) |
DHCP servers listen on UDP port 67 |
| Client MAC (chaddr) | Client's hardware address | Server uses this to identify the client and track the offer |
| Transaction ID (xid) | Random 32-bit number | Matches the DORA messages together — the Offer/Request/Ack all echo this same ID |
4. DHCP Offer — Message 2
Any DHCP server that receives the Discover and has an available IP address responds with a DHCP Offer. The Offer proposes an IP address and all associated configuration parameters — but the client has not yet accepted.
| Field | Value | Why |
|---|---|---|
| Source IP | DHCP server's IP (e.g., 192.168.1.1) |
Server identifies itself so the client can choose which Offer to accept |
| Destination IP | 255.255.255.255 (or client MAC via unicast) |
Broadcast because client still has no IP; some servers unicast to client MAC |
| yiaddr ("your IP") | Proposed IP for the client (e.g., 192.168.1.15) |
The IP being offered — temporarily reserved by the server |
| Options | Subnet mask, gateway, DNS, lease time, server ID | Complete network configuration package |
| Transaction ID (xid) | Same value from the Discover | Client matches the Offer to its original Discover request |
5. DHCP Request — Message 3
The client sends a DHCP Request to formally accept one of the Offers received. This message is still sent as a broadcast — even though the client now knows the server's IP — because there may be multiple DHCP servers on the network, and all of them need to know which one was chosen so the others can release their temporarily reserved IPs.
| Field | Value | Why |
|---|---|---|
| Source IP | 0.0.0.0 |
Still no confirmed IP — the lease is not final until the ACK |
| Destination IP | 255.255.255.255 |
Broadcast — all DHCP servers see this; unchosen servers release their reserved IPs |
| Requested IP (Option 50) | The IP from the accepted Offer (e.g., 192.168.1.15) |
Specifies which IP the client is formally requesting |
| Server Identifier (Option 54) | IP of the chosen DHCP server (e.g., 192.168.1.1) |
Tells all servers which one was selected — unchosen servers see this and release their offers |
6. DHCP Acknowledge (ACK) and NAK — Message 4
The selected DHCP server finalises the lease by sending a DHCP ACK. The client receives this, applies the configuration, and begins using the IP address. If the server cannot honour the request, it sends a DHCP NAK instead.
DHCP ACK
- Confirms the IP address lease is granted.
- Contains the full configuration: IP, mask, gateway, DNS, lease time, and all options.
- After receiving the ACK, the client performs an ARP probe (optional but common) to verify no other device already uses the offered IP — a precaution against duplicate IPs if the server's conflict detection failed.
- If ARP probe detects a conflict, the client sends a DHCP Decline back to the server and the server marks that IP as conflicted.
DHCP NAK (Negative Acknowledgement)
A DHCP NAK is sent by the server when it cannot or will not honour the Request:
- The requested IP address is no longer available (already assigned to another client).
- The client has moved to a different subnet and its previously held IP is no longer valid for the current network.
- The lease has expired and the server no longer recognises the client's binding.
DHCP Decline
If the client receives a DHCP ACK but its ARP probe detects the offered IP is already in use, it sends a DHCP Decline to the server. The server marks that IP as conflicted and withholds it from future assignments until an administrator clears the conflict. The client then restarts DORA.
7. DHCP Lease Renewal — T1, T2, and Expiry
DHCP leases are temporary. Clients must renew their leases before they expire to maintain uninterrupted network connectivity. The renewal process uses three timers:
| Timer | When | Action | Unicast or Broadcast |
|---|---|---|---|
| T1 (Renewal) | 50% of lease duration | Client sends DHCP Request unicast directly to original server to renew | Unicast to original server |
| T2 (Rebinding) | 87.5% of lease duration | If T1 failed (no ACK from original server), client broadcasts DHCP Request to find any available DHCP server to rebind the lease | Broadcast to 255.255.255.255 |
| Expiry | 100% of lease duration | Lease expired. Client immediately stops using the IP, clears configuration, and restarts the full DORA process from scratch | DORA restart (Broadcast) |
Lease Renewal Timeline
Lease: 86400 seconds (24 hours)
│ 0s 43200s 75600s 86400s │
│ ├──────────────────┼────────────────┼────────────────────┤ │
│ Lease Start T1 (50%) T2 (87.5%) Expiry │
│ IP Assigned Unicast Broadcast │
│ Request to Request to any │
│ original available server │
│ server (rebinding) │
Typical T1 for a 24-hour lease = 12 hours
Typical T2 for a 24-hour lease = 21 hours
8. DHCP Relay Agent — Crossing Subnet Boundaries
DHCP broadcasts (Discover and Request) are stopped by routers — they do not cross Layer 3 boundaries. In networks where the DHCP server is on a different subnet from the clients, a DHCP Relay Agent is needed on the router or Layer 3 switch interface connecting to the client subnet.
Client Subnet Router (Relay) DHCP Server
192.168.10.0/24 GigabitEthernet0/0 10.0.0.5
│ │ │
│─── DHCP DISCOVER (broadcast)─▶│ │
│ Src: 0.0.0.0:68 │ │
│ Dst: 255.255.255.255:67 │── Unicast DISCOVER──▶│
│ │ Src: 192.168.10.1 │
│ │ Dst: 10.0.0.5:67 │
│ │ giaddr: 192.168.10.1│
│ │ │
│ │◀── DHCP OFFER ───────│
│◀── DHCP OFFER ────────────────│ │
│ Offer from 10.0.0.5 │ │
│ for 192.168.10.x subnet │ │
Key: giaddr (Gateway IP) = relay agent's interface IP on the client subnet
The server uses giaddr to select the correct pool (192.168.10.0/24)
Configuring DHCP Relay (ip helper-address)
! On the router interface or Layer 3 switch SVI facing the client subnet: Router(config)# interface GigabitEthernet0/0 Router(config-if)# ip helper-address 10.0.0.5 ! DHCP server's IP
ip helper-address is more than just DHCP. By default, it also forwards
several other UDP broadcast protocols: TFTP (69), DNS (53), Time (37), NetBIOS (137/138),
IEN-116 (42), and TACACS (49). If you only want to relay DHCP and nothing else, disable
the others with no ip forward-protocol udp <port>.
9. DHCP Message Types — Complete Reference
| Message Type | Sent By | Purpose | Transport |
|---|---|---|---|
| DHCP Discover | Client | Locate available DHCP servers | Broadcast (0.0.0.0 → 255.255.255.255) |
| DHCP Offer | Server | Propose an IP address and configuration | Broadcast or unicast to client MAC |
| DHCP Request | Client | Accept an Offer (initial) or renew/rebind a lease | Initial: Broadcast; T1 renewal: Unicast; T2 rebind: Broadcast |
| DHCP ACK | Server | Confirm and finalise the IP lease | Broadcast or unicast to client |
| DHCP NAK | Server | Reject the Request — IP unavailable or client on wrong subnet | Broadcast to 255.255.255.255 |
| DHCP Decline | Client | Inform server offered IP is already in use (detected via ARP probe) | Unicast to server |
| DHCP Release | Client | Voluntarily return the IP lease to the server before expiry | Unicast to server |
| DHCP Inform | Client | Request configuration options from server without requesting an IP (client already has a static IP but needs DNS/gateway info) | Unicast to server |
10. APIPA — When DHCP Fails
If a client sends DHCP Discover messages repeatedly and receives no response, it falls back to APIPA (Automatic Private IP Addressing). The client self-assigns a link-local address in the 169.254.0.0/16 range — chosen randomly from 169.254.1.0 to 169.254.254.255, then verified by ARP probe to ensure uniqueness.
- APIPA allows limited local communication between devices on the same segment that all have APIPA addresses.
- There is no gateway or DNS — APIPA addresses cannot reach the internet or other subnets.
- The client continues sending DHCP Discover broadcasts in the background every few minutes — it will switch to a DHCP-assigned address the moment a server responds.
- On Windows, the fallback delay before APIPA is approximately 60 seconds (after 4 Discover attempts).
ip helper-address on the VLAN SVI, or DHCP Snooping
blocking the response.
11. Common DHCP Options — What Gets Sent in the Offer/ACK
DHCP parameters beyond the IP address itself are carried as options in the DHCP message. Each option has a standardised option code number.
| Option Code | Parameter | Notes |
|---|---|---|
| 1 | Subnet Mask | Defines the network prefix length |
| 3 | Router (Default Gateway) | Can list multiple gateways in priority order |
| 6 | DNS Servers | Up to 8 DNS servers in order of preference |
| 15 | Domain Name | DNS search domain (e.g., company.local) |
| 42 | NTP Servers | Network Time Protocol servers for clock sync |
| 43 | Vendor Specific Info | Used by APs (Cisco WLC discovery), IP phones |
| 51 | Lease Time | Seconds until lease expires; determines T1 and T2 |
| 53 | DHCP Message Type | Identifies the message as Discover/Offer/Request/ACK/NAK etc. |
| 54 | DHCP Server Identifier | IP of the server sending this message — used by client to identify chosen server |
| 58 | T1 Renewal Time | Seconds until first unicast renewal attempt (default: 50% of lease) |
| 59 | T2 Rebinding Time | Seconds until broadcast rebinding attempt (default: 87.5% of lease) |
| 43 / 66 / 67 | TFTP Server / Boot File | PXE boot configuration for diskless devices |
12. DHCP Security — Threats and Defences
DHCP has no built-in authentication — any device can act as a DHCP server on a network segment. This creates two significant attack vectors:
Rogue DHCP Server Attack
An attacker connects an unauthorised device running a DHCP server. When clients broadcast DHCP Discovers, the rogue server responds faster than the legitimate server and offers clients a malicious gateway (the attacker's IP) — redirecting all traffic through the attacker (Man-in-the-Middle).
Normal: Client ─── DHCP Discover ──▶ Legitimate Server
◀── DHCP Offer ───── GW: 192.168.1.1 (real router)
Attack: Client ─── DHCP Discover ──▶ Rogue Server (wins race)
◀── DHCP Offer ───── GW: 192.168.1.99 (attacker's machine)
Client sends all traffic through attacker's machine!
DHCP Starvation Attack
An attacker sends thousands of DHCP Discovers with spoofed MAC addresses, exhausting the DHCP server's address pool. Legitimate clients receive no IP addresses (pool is "starved"). This is a Denial of Service (DoS) attack against DHCP.
Defence — DHCP Snooping
Cisco switches implement DHCP Snooping as the primary defence:
- Ports are classified as trusted (connected to legitimate DHCP servers or uplinks) or untrusted (connected to end clients).
- DHCP Offer and DHCP ACK messages arriving on untrusted ports are dropped — the switch blocks all rogue server responses at the hardware level.
- A DHCP Snooping Binding Table records all validated DHCP leases (IP, MAC, VLAN, port, expiry) — used by DAI (Dynamic ARP Inspection) to prevent ARP spoofing.
- Rate limiting on untrusted ports prevents DHCP starvation attacks.
13. Real-World Examples
Example 1 — Home Network
- Laptop sends DHCP Discover broadcast (0.0.0.0 → 255.255.255.255)
- Home router (DHCP server) responds with DHCP Offer: 192.168.1.10/24, GW: 192.168.1.1, DNS: 8.8.8.8, Lease: 24 hours
- Laptop broadcasts DHCP Request accepting 192.168.1.10
- Router responds with DHCP ACK — lease confirmed
- After 12 hours (T1), laptop unicasts DHCP Request to router to renew
- Router responds with DHCP ACK — lease extended for another 24 hours
Example 2 — Enterprise Multi-VLAN Network
ip helper-address 10.0.0.5:
- PC sends DHCP Discover broadcast on VLAN 20
- Layer 3 switch intercepts the broadcast, inserts giaddr = 192.168.20.1 (the SVI IP), and unicasts the Discover to 10.0.0.5
- DHCP server sees giaddr = 192.168.20.1, selects the VLAN20_POOL (192.168.20.0/24)
- Server sends DHCP Offer for 192.168.20.15 back to the relay
- Relay forwards Offer to PC on VLAN 20
- DORA completes — PC gets 192.168.20.15/24, GW: 192.168.20.1
Example 3 — DHCP Failure (APIPA fallback)
ip helper-address:
- PC sends 4 DHCP Discovers over ~60 seconds — no response
- PC falls back to APIPA: assigns itself 169.254.x.x address
- PC can ping other APIPA hosts on same VLAN but cannot reach internet or other subnets
- Admin adds
ip helper-address 10.0.0.5to the SVI - PC's next DHCP Discover is relayed — DORA completes — PC gets proper IP
14. Common Misconceptions About DHCP
-
"The DHCP Request is unicast to the chosen server."
The initial DHCP Request (message 3 of DORA) is always broadcast — even though the client knows the server's IP. This is intentional: all other DHCP servers that sent Offers need to see the broadcast Request containing the chosen server's ID so they can release their temporarily reserved IPs. Only the T1 renewal Request is unicast. -
"DHCP only provides an IP address."
DHCP delivers a complete network configuration package via options: subnet mask, default gateway, DNS servers, domain name, NTP servers, lease time, and more. The IP address is just one of many parameters. -
"A DHCP ACK means the IP is permanently assigned."
A DHCP ACK grants a lease — a time-limited assignment. The client must renew the lease at T1 or T2 to keep the IP. If the lease expires without renewal, the IP returns to the pool and the client loses it. -
"169.254.x.x means DHCP is configured wrong on the server."
An APIPA address means the client received no DHCP response — the problem is often with the network path (missing relay, blocked port, wrong VLAN) rather than the server itself. The server may be working perfectly for other clients. -
"DHCP works across routers without any special configuration."
DHCP uses broadcasts which are stopped at Layer 3 boundaries. A relay agent (ip helper-addresson each client-facing interface) is required whenever the DHCP server is on a different subnet than the clients.
15. Key Points & Exam Tips
- DHCP uses UDP port 67 (server) and UDP port 68 (client).
- DORA sequence: Discover → Offer → Request → Acknowledge — client sends D and R; server sends O and A.
- DHCP Discover: Src 0.0.0.0, Dst 255.255.255.255 — broadcast because client has no IP.
- DHCP Request (initial): also broadcast — not unicast — so other servers release their reserved IPs.
- T1 = 50% of lease → unicast Request to original server.
- T2 = 87.5% of lease → broadcast Request to any available server.
- DHCP NAK: server rejects the Request → client restarts full DORA.
- DHCP Decline: client rejects the Offer (ARP probe detected IP in use) → server marks IP as conflicted, client restarts DORA.
- DHCP Release: client voluntarily returns IP early.
- APIPA (169.254.x.x): client self-assigns when no DHCP response after ~60s; local-only, no gateway.
- ip helper-address on the client-facing interface converts DHCP broadcasts to unicast for the DHCP server — required when server is on different subnet.
- DHCP Snooping: blocks rogue DHCP servers by dropping Offer/ACK on untrusted ports.
Related pages: DHCP Overview | DHCP Snooping | How DNS Works | NTP Synchronisation | MAC Addresses | VLANs | Common Port Numbers | DHCP Server Configuration Lab | DHCP Relay Agent Lab | DHCP Snooping & DAI Lab | Troubleshooting DHCP Clients Lab