Sub topic 12
Inspecting and troubleshooting DHCP with common tools
This chapter assumes you know the Discover, Offer, Request, Acknowledge (DORA) exchange, lease timers, DHCP options, and what a relay agent does. It shows how to watch DHCP on the wire, force a new lease, and work out why a client has no address or the wrong one.
Start with the client
Check what the client actually received before you capture any packets. On Windows, ipconfig /all lists the DHCP server address, the lease start and expiry, and the options (gateway, DNS). On Linux, ip -4 addr show eth0 shows the assigned address.
A 169.254.x.x address means the client got no answer from any server and fell back to link-local. Treat it as a sign that DORA failed, not as a configuration to fix on the client.
To force a fresh exchange, release and renew the lease:
# Linux (ISC dhclient)
sudo dhclient -r eth0 # release the current lease
sudo dhclient -v eth0 # request a new lease, verbose output
ip -4 addr show eth0 # check the address that was assigned
:: Windows (Command Prompt)
ipconfig /release
ipconfig /renew
ipconfig /allThe first three lines run on Linux. The last three run on Windows. The -v flag prints each message the client sends and receives, so you often see the failure point without a capture.
Capture the exchange
Run a capture on the client, or on a machine on the same segment, while the client renews:
sudo tcpdump -n -i eth0 -vv 'udp and (port 67 or port 68)'The filter matches UDP ports 67 (server) and 68 (client). In the output, look for the message type in each packet and the options that follow it.
Match the symptom to the cause
| Symptom | Likely cause | What to check |
|---|---|---|
| Discover leaves the client, no Offer | Server down, wrong VLAN, relay missing, or pool exhausted | Server service and logs, switch port VLAN, relay configuration, free addresses in the scope |
| Offers arrive from two sources | A rogue or second server on the segment | The server identifier in each Offer |
| Client gets an address with the wrong gateway or DNS | Wrong options in the scope, or an unintended server answered | Option 3 and option 6 in the Offer |
| Client repeats Discover after an Acknowledge | Client declined the address, often after an ARP conflict | Decline messages and duplicate addresses |
| Request followed by NAK | Client asked for an address that is invalid on this subnet | Whether the client moved networks, and the scope range |
| Works on one subnet, fails on another | Relay agent missing or pointing at the wrong server | The relay helper address and the server scope for that subnet |
Read the server side
The server log usually names the reason directly. With dnsmasq, which the earlier scope example used, run it with log-dhcp added to the configuration. Each Discover, Offer, Request, and Acknowledge then appears with the MAC address and the address involved. Check that the server's dhcp-range covers the subnet the request came from, and that no reservation conflicts with an address in the pool.
When the capture shows a relayed request, the relay's own address appears in the giaddr field. The server picks the scope that matches that address. If no scope matches, the server stays silent.
Check the timers
If a client loses its address long after it connected, compare the lease time with the renewal timers. For a 24-hour lease, the defaults work out like this:
lease_seconds = 86400 # 24-hour lease
t1 = lease_seconds * 0.5 # default renewal time: 50% of the lease
t2 = lease_seconds * 0.875 # default rebinding time: 87.5% of the lease
print(f"Renew (unicast to the original server) at {t1:.0f} s")
print(f"Rebind (broadcast to any server) at {t2:.0f} s")
print(f"Lease expires at {lease_seconds} s")The output is 43200 s and 75600 s. If the original server is offline at T1, the client keeps trying and then broadcasts at T2. A client that loses its address near expiry usually means no server answered either attempt.
Exercise
A client shows the address 169.254.37.12. A capture on its switch port shows repeated Discover messages and no Offer. Name two checks that fit this evidence.
Show answer
Check that the DHCP server service is running and has free addresses in the scope for this subnet. Also check that the client's VLAN has a path to the server, either on the same segment or through a relay agent pointing at the correct server.
Exercise
You capture Offers from two different server identifiers, and some clients get the wrong gateway. What is the likely cause, and what switch feature limits it?
Show answer
A second, unintended DHCP server (rogue or misconfigured) is answering on the segment. DHCP snooping limits this by allowing server replies only from trusted switch ports.