The Plain Picture#
You check into a hotel. You don't pick a room number yourself — you ask reception, and they hand you a key card with your room number, the Wi-Fi password and the breakfast timing. The card expires at checkout.
The Real Name#
DHCP (Dynamic Host Configuration Protocol) gives a device, when it joins a network:
an IP address,
the subnet (e.g. /24 — Chapter 5),
the default gateway (Chapter 7),
which DNS servers to use (the internet's "phone book", Networking 3: DNS, HTTP and HTTPS),
for a limited time called a lease (hours or days). The device renews the lease before it expires.
Under the Hood#
Your laptop has no address yet, so it can't send a normal packet to anyone. It uses broadcasts (Chapters 3 and 6). The four-step exchange is often remembered as DORA:
Laptop (no IP yet) DHCP server (usually your router)
│ 1. DISCOVER (broadcast) "Any DHCP server here?" │
│ ───────────────────────────────────────────────────────▶ │
│ 2. OFFER "You can have 192.168.1.37 for 24 hours" │
│ ◀─────────────────────────────────────────────────────── │
│ 3. REQUEST (broadcast) "I'll take 192.168.1.37" │
│ ───────────────────────────────────────────────────────▶ │
│ 4. ACK "Confirmed. Gateway 192.168.1.1, DNS ..." │
│ ◀─────────────────────────────────────────────────────── │If no server answers, the device gives itself a 169.254.x.x address (Chapter 6) — and has no internet.
Servers in data centres usually get their address from DHCP too, even in the cloud — or they have a static (fixed, manually set) address.
Check yourself
3 questionsName four things DHCP gives a device.
Show answerHide answer
IP address, subnet, default gateway, DNS servers (plus a lease time).
What does DORA stand for?
Show answerHide answer
Discover, Offer, Request, Acknowledge.
Why does the laptop use broadcasts for DHCP?
Show answerHide answer
It doesn't have an IP address yet and doesn't know the server's, so it can only shout to everyone on the LAN.