Sub topic 12
Inspecting and Troubleshooting DHCP with Common Tools
This chapter assumes you know IPv4 addresses and subnet masks, what a default gateway and a DNS server do, and the Discover, Offer, Request, Acknowledge (DORA) exchange. It also assumes you have met leases, relay agents and the 169.254.0.0/16 fallback in earlier chapters. Here you will use that knowledge to find out why a client has no address or the wrong one.
A method for DHCP problems
Most DHCP faults fall into a few groups. Work through them in order and stop when you find the cause.
- Check what the client has now: address, lease times, server address.
- Check whether the client sends Discover and whether anything answers.
- If a server answers, check what it offers and whether the client accepts.
- If nothing answers, check the path: the VLAN, the relay agent, the switch security features, the server's pool.
The diagram shows the same decision flow.
Step 1: Read the client's current state
Start on the client. It tells you what it believes, and that often narrows the problem at once.
On Linux, the commands release the old lease, ask for a new one with verbose output, and show the result. On Windows, ipconfig /all shows the DHCP server address and the lease times.
# 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 two halves are for different systems. Run the Linux lines in a shell and the Windows lines in Command Prompt. The :: line is a comment in batch syntax.
Read the output for these fields:
| Field | What it tells you |
|---|---|
| IPv4 address | A 169.254.x.x value means no server answered. An address in an unexpected subnet means the wrong server or the wrong VLAN. |
| DHCP server | The address of the server that granted the lease. If it is not the server you expect, a second server exists. |
| Lease obtained and lease expires (Windows) | Shows the lease length. Compare it with the server's configured value. |
| Default gateway and DNS servers | Compare with the router and dns-server options you configured. |
The verbose dhclient -v output also prints each step, such as DHCPDISCOVER, DHCPOFFER, DHCPREQUEST and DHCPACK. If you see Discover lines repeated with no Offer, the client is not getting a reply. The dhclient retry intervals grow over time, so be patient before you decide nothing is coming back.
Step 2: Capture the exchange
If the client output does not explain the fault, look at the packets. The tcpdump command below captures DHCP traffic on eth0.
sudo tcpdump -n -i eth0 -vv 'udp and (port 67 or port 68)'The options are:
-nturns off name lookups, so addresses stay as numbers and the capture does not trigger DNS traffic.-i eth0selects the interface.-vvprints the decoded DHCP fields, including options.- The filter keeps only UDP packets with port 67 (server) or 68 (client) on either side.
Capture on the client if you can, because that shows what the client sends and receives. Capture on the server to see what arrives there. Capturing at both ends tells you where a packet is lost. Run the capture, then renew the lease from another terminal.
A healthy exchange looks like this, shortened:
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request, DHCP-Message: Discover
192.168.1.1.67 > 192.168.1.100.68: BOOTP/DHCP, Reply, Your-IP 192.168.1.100,
DHCP-Message: Offer, Server-ID 192.168.1.1, Lease-Time 43200,
Subnet-Mask 255.255.255.0, Default-Gateway 192.168.1.1
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request, DHCP-Message: Request
192.168.1.1.67 > 192.168.1.100.68: BOOTP/DHCP, Reply, Your-IP 192.168.1.100,
DHCP-Message: AcknowledgeThe exact wording varies by tcpdump version. Note the source address 0.0.0.0 and the destination 255.255.255.255 on the client messages. The client has no address yet, so it uses the limited broadcast. The server may reply by broadcast or by unicast to the offered address, depending on the client's broadcast flag.
What each capture result means
| What you see | Likely cause |
|---|---|
| Discover leaves the client, nothing returns | No server on that broadcast domain, a relay is missing or misconfigured, a switch drops the Offer, or the server is stopped. |
| Discover arrives at the server, no Offer is sent | The pool is exhausted, the server has no scope for that subnet, the server is not listening on that interface, or a firewall blocks it. |
| Offer is sent but the client never sends Request | The Offer did not reach the client, or the client rejected it. Check the path back. |
| Request is followed by a NAK | The client asked for an address the server will not give. The client then restarts at Discover. |
| Two different Offers for one Discover | There are two servers. This is a rogue server or an overlapping scope. |
| Client sends Decline after the Acknowledge | The client found the address already in use, for example through an ARP probe. |
Step 3: Check the server side
When the capture shows Discover arriving but no useful reply, look at the server. With dnsmasq, this configuration defines a pool, the gateway and DNS options, and a reservation.
# /etc/dnsmasq.conf (DHCP part only)
interface=eth0
# Hand out 192.168.1.100-192.168.1.200 with a 12-hour lease
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h
# Option 3 (router) and option 6 (DNS server)
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.1
# Reservation: this MAC address always gets the same IP
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.1.50Use this file to check four things:
- Interface. The
interface=eth0line limits dnsmasq to one interface. If the clients are on another interface, or arrive through a relay, the server will not answer. - Range and mask. The range must sit inside the subnet that the clients belong to. A range on the wrong subnet gives no Offer, because the server cannot match the request to a scope.
- Pool size against demand. A pool of 101 addresses with a 12-hour lease fills up if more than 101 distinct devices appear within that time. Phones that come and go can hold leases for hours after they leave.
- Reservations. A reserved address must not also sit inside a range handed to other clients without the server knowing. A MAC address typed wrongly means the device receives a pool address instead of the reserved one.
dnsmasq writes leases to a file, commonly /var/lib/misc/dnsmasq.leases, and logs DHCP messages to syslog when you add log-dhcp. Other servers keep similar data in different places. ISC dhcpd uses dhcpd.leases, and Windows Server shows leases in the DHCP console. Check the lease table for the client's MAC address. If it is missing, the request never got a lease. If it is present with a different address than the client reports, the client may be using an older lease or a second server's lease.
Step 4: Check the path
If Discover leaves the client and never reaches the server, the fault lies between them.
- Same subnet. Confirm that the client port is in the right VLAN. A client in the wrong VLAN receives an address for another network or nothing at all.
- Different subnet. The router needs a relay agent (often called
ip helper-addresson Cisco devices) that forwards broadcasts to the server's unicast address. The server then needs a scope that matches the relay's interface address, which the relay writes into thegiaddrfield. A missing scope for that address means no Offer. - Switch security. DHCP snooping drops server replies that arrive on untrusted ports. If the legitimate server's port or the uplink toward it is not marked trusted, Offers are dropped. Check the switch's snooping counters and port trust settings.
- Firewalls. The server host must accept UDP 67. A host firewall that blocks it produces the same symptom as a stopped service.
Timers: check renewal behavior
Some faults appear only hours after a client first connects, when it tries to renew. The default timers are 50% of the lease for renewal (T1) and 87.5% for rebinding (T2). The script computes them for a 24-hour lease.
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 for renewal and 75600 s for rebinding. A client renews by unicast to the server that granted the lease. If that server went down or moved, the client keeps using its address until T2, then broadcasts to any server. A network that works in the morning and fails at T1 or T2 suggests that the original server cannot be reached by unicast. A change of server address or a firewall rule that allows only broadcast traffic are typical causes.
To test renewal quickly, set a short lease such as 2 minutes on a test scope. T1 is then 60 seconds, and you can watch the unicast Request in a capture without waiting hours. Return the lease to its normal length afterward.
Common faults and their signs
| Symptom | Where to look first |
|---|---|
| Client has 169.254.x.x | Capture for Discover and Offer. Check the VLAN, the relay and the server status. |
| Client has an address in the wrong subnet | Look for a rogue server or a second router handing out leases. Check the DHCP server field in `ipconfig /all`. |
| Address works but names do not resolve | The Offer is missing option 6, or it lists a wrong DNS server. Read the options in the capture. |
| Address works but traffic does not leave the subnet | Option 3 is missing or wrong. Check the default gateway. |
| Two devices report the same address | A static address sits inside the pool. Exclude it from the range or convert it to a reservation. |
| Some clients succeed and others fail | The pool may be exhausted, or one switch port is blocked by security settings. |
| Reserved device gets a different address | The MAC address in the reservation does not match the client, or the client uses a client identifier (option 61) that differs from the MAC. |
Exercise
A laptop on the 192.168.1.0/24 network shows 169.254.37.12. A capture on the laptop shows repeated Discover messages from 0.0.0.0 to 255.255.255.255 and no replies. A capture on the DHCP server, which sits in another subnet, shows no DHCP packets at all. Name the two most likely causes and the next check for each.
Show answer
The Discover never reaches the server, so the fault lies between them. Likely cause one is a missing or misconfigured relay agent on the router for the laptop's subnet. Check for an ip helper-address (or equivalent) pointing to the server. Likely cause two is that the laptop's switch port is in the wrong VLAN or DHCP snooping or a filter drops the broadcast. Check the port's VLAN and the switch's snooping and ACL counters. If packets did reach the server, the next step would be to check for a scope that matches the relay address.
Exercise
A client has a valid address and can ping the gateway, but it cannot open websites by name. Which DHCP option do you check, and how do you check it?
Show answer
Check option 6, the DNS server option. Run ipconfig /all on Windows or look at the resolver settings on Linux to see which DNS server the client received. Then capture the Offer or Acknowledge with tcpdump -n -i eth0 -vv 'udp and (port 67 or port 68)' and read the Domain-Name-Server field. If it is missing or wrong, fix the dhcp-option=option:dns-server line on the server (or the equivalent setting) and renew the lease.