Sub topic 7
DHCP and APIPA
This chapter assumes you know how an IPv4 address, subnet mask and default gateway work, and that you can use the Windows command prompt. It covers how a client gets its address automatically, what happens when that fails, and how to fix it.
What DHCP Does
The Dynamic Host Configuration Protocol (DHCP) hands out IP settings automatically. A DHCP server, usually the SOHO router or a Windows Server, leases each client an address, a subnet mask, a default gateway and DNS server addresses. A lease is a temporary loan of an address for a set time. DHCP servers listen on UDP port 67 and clients use UDP port 68.
Clients use broadcasts at first because they have no address yet. The exchange has four steps, often remembered as DORA.
Halfway through the lease, the client asks to renew it. If the client leaves the network, the address returns to the server's pool when the lease expires.
Reservations
A DHCP reservation ties one address to one device's MAC address. The device still gets its settings from DHCP, but it always receives the same address. Use reservations for printers, servers and cameras. This differs from a static address, which you type into the device by hand. A reservation keeps all addressing in one place, so you can change the gateway or DNS servers once on the server.
APIPA
Automatic Private IP Addressing (APIPA) is a Windows fallback. If a DHCP client gets no reply, it gives itself an address in the 169.254.0.0/16 range with the mask 255.255.0.0. The client can then talk to other APIPA hosts on the same local segment. It has no default gateway, so it cannot reach other networks or the internet.
A 169.254.x.x address on a client almost always means DHCP failed. Common causes are:
- The DHCP server is down or its address pool is full.
- A cable is faulty or a switch port is bad.
- The client is on the wrong VLAN or Wi-Fi network.
Fixing a Bad Lease
Start by checking what the client has. Then release the lease and ask for a new one.
ipconfig /all
ipconfig /release
ipconfig /renewipconfig /all shows the DHCP server address and the lease times. If /renew still returns 169.254.x.x, the client cannot reach a DHCP server, so check the cable, the switch port and the server.
Another common problem is an address conflict. This happens when a static address falls inside the DHCP pool, so two devices end up with the same address. Exclude static addresses from the pool, or use reservations instead.
| Situation | Address source | Typical result |
|---|---|---|
| Normal client | DHCP lease | Full access with a gateway |
| Server or printer | Reservation | Same address every time |
| DHCP unreachable | APIPA | 169.254.x.x, local only |
Exercise
A laptop shows the address 169.254.17.5 and cannot open websites, but it can reach another laptop on the same switch that also shows a 169.254 address. What is the likely cause, and what are your first two steps?
Show answer
Both laptops are using APIPA because neither can reach a DHCP server. First, check that the DHCP server or router is running and that the cables and switch ports are working. Second, run ipconfig /release and ipconfig /renew on a laptop to request a new lease.