Sub topic 9
When no server answers: the 169.254.0.0/16 fallback
This chapter assumes you know IPv4 addresses and subnet masks, what a default gateway does, and the Discover, Offer, Request, Acknowledge (DORA) exchange from the previous chapters.
What the client does when DHCP fails
A DHCP client sends a Discover message and waits for an Offer. If no server answers, the client retries a few times with increasing delays. Typical implementations wait about 4, 8, 16 and 32 seconds, with some random jitter, before they give up. The exact timing depends on the operating system.
After the retries fail, many clients assign themselves a link-local address from the block 169.254.0.0/16. Microsoft calls this feature APIPA (Automatic Private IP Addressing). The standard behind it is RFC 3927, "Dynamic Configuration of IPv4 Link-Local Addresses".
A link-local address is valid only on the local link, which is the one LAN segment the host is attached to. Routers must not forward packets to or from 169.254.0.0/16, so these addresses never reach another subnet.
How the client picks and checks an address
The client does not ask anyone for this address. It chooses one itself:
- It picks a pseudo-random address in 169.254.1.0 to 169.254.254.255. The first and last 256 addresses of the block are reserved.
- It sends ARP probes, which are ARP requests with a sender IP of 0.0.0.0, asking whether anyone already uses that address.
- If another host answers, or also probes for the same address, the client picks a different one and probes again.
- If nothing answers, the client announces the address with ARP announcements and starts using it. The mask is 255.255.0.0.
No default gateway or DNS server is set, because no server provided them.
Recovery
The fallback is not permanent. A client with a link-local address keeps trying DHCP in the background. Windows retries about every 5 minutes. When a server finally answers, the client drops the 169.254.x.x address and uses the leased one.
What works and what does not
With a link-local address, two hosts on the same segment can talk to each other, provided both have fallen back. Local services that use the link, such as mDNS or file sharing by address, can still work. Anything that needs a router does not work: no Internet access, no other subnets, and no DNS unless a name service is reachable by other means.
This is why a 169.254.x.x address is a useful symptom. It tells you the client is working and its network card is up, but it received no DHCP answer.
Reading the symptom
Check the address with the tools you already know.
# Linux
ip -4 addr show eth0
# Windows (Command Prompt)
ipconfig /allOn Windows, ipconfig /all shows "Autoconfiguration IPv4 Address" and "DHCP Enabled: Yes" when APIPA is in use. Common causes of a 169.254.x.x address are:
- The DHCP server is down or its pool is exhausted.
- The cable, Wi-Fi association, or VLAN assignment is wrong, so Discover never reaches a server.
- A relay agent is missing or misconfigured on a segment that has no local server.
- A switch security feature, such as DHCP snooping, drops the traffic. This is covered in a later chapter.
Exercise
A laptop shows the address 169.254.37.12 with mask 255.255.0.0 and no default gateway. Two colleagues on the same switch have normal 192.168.1.x addresses. What does this tell you, and what is the first thing you would check?
Show answer
The laptop sent Discover messages, got no Offer, and assigned itself a link-local address after the retries. Its network stack works, so the problem is that Discover or Offer is not getting through. Because the colleagues receive leases, the server is probably running, so check the laptop's connection: the cable or Wi-Fi network, the VLAN or port configuration, and any DHCP snooping or port-security rule on its switch port. Capturing with tcpdump on UDP ports 67 and 68 shows whether Discover leaves the laptop and whether an Offer returns.
Exercise
Why can two hosts that both fell back to 169.254.x.x addresses talk to each other, but neither can reach the Internet?
Show answer
Both addresses are in the same 169.254.0.0/16 network, so they communicate directly on the local segment using ARP. Neither has a default gateway, and routers never forward link-local traffic, so packets cannot leave the segment.