Skip to main content
Explainer

How DHCP works

DHCP — the Dynamic Host Configuration Protocol — is what hands your phone an IP address seconds after it joins Wi-Fi. Before DHCP existed, every device on a network needed a statically-assigned IP, a gateway, a netmask, and a list of DNS servers, hand-configured. DHCP automates all of that.

The four-step handshake (DORA)

Mnemonic: Discover, Offer, Request, Acknowledge.

  1. Discover. Your device broadcasts a DHCPDISCOVER packet to 255.255.255.255 — "is there a DHCP server out there? I need an IP."
  2. Offer. The DHCP server (usually your router) responds with a DHCPOFFER: "here's an IP from my pool, here's the gateway, here are the DNS servers, the lease is valid for 24 hours."
  3. Request. Your device sends DHCPREQUEST formally accepting the offered IP. The accept is broadcast so any other DHCP servers on the network know it's taken.
  4. Acknowledge. Server replies DHCPACK confirming the assignment. Device configures the interface and starts using the IP.

Lease lifecycle

A DHCP lease isn't forever. Halfway through the lease period (the "T1" timer), your device sends DHCPREQUEST to the same server asking to renew. If the server replies, the lease extends. If it doesn't reply by 87.5% of the lease (the "T2" timer), the device broadcasts looking for any DHCP server willing to extend the lease. If even that fails, the device eventually drops back to DISCOVER.

For sticky IPs, most home routers and DHCP servers support reservations keyed on MAC address: "device with MAC 3c:5a:b4:00:00:00 always gets 192.168.1.50." Cleaner than configuring static IPs on each device.

IPv6 alternatives

When DHCP misbehaves

If you're trying to figure out your assigned address, the home page shows your public IP — but for the local one, check your router admin or your OS network settings. Local IPs are private (RFC 1918) — see the glossary entry.