How does DHCP hand out IP addresses on a network?
Every time your laptop joins a Wi-Fi network, it needs an IP address, a gateway and DNS servers before it can do anything useful. Almost nobody types these in by hand anymore, thanks to DHCP, the Dynamic Host Configuration Protocol.
The four-step exchange (DORA)
- Discover. The new device has no address yet, so it broadcasts a message to the local network: "Is there a DHCP server out there?"
- Offer. A DHCP server (often your home router) replies with an available address and settings.
- Request. The device formally asks for that offered address. This step matters on networks with more than one server.
- Acknowledge. The server confirms, and the device configures itself.
Leases
Addresses are not given forever. Each one comes with a lease time. Devices try to renew partway through the lease, so a laptop that stays connected keeps the same address, while one that leaves for a week may get a different one when it returns.
Reservations vs static addresses
If you want a printer or home server to always have the same address, you have two options:
- DHCP reservation: the router always hands that device the same address, based on its MAC address. Easy to manage centrally.
- Static configuration: you set the address on the device itself. Works without DHCP, but you must avoid conflicts with the router's pool.
In the cloud
Cloud VPCs use DHCP too, usually invisibly. The provider assigns private addresses and passes along DNS settings when an instance boots.
Discussion:
- Do you prefer reservations or static IPs for home lab gear, and why?
- Have you ever chased a problem that turned out to be two devices with the same address?
Comments · 3
The DORA acronym finally stuck for me: Discover, Offer, Request, Acknowledge. Once you read about it in that order, it makes sense.
Router runs the DHCP server in most home networks. Address leases expire and renew, which is why your device's IP can occasionally change.
Good thing to know before setting up an office: reserve addresses for printers or servers rather than letting them float, or you'll chase connectivity ghosts.