How devices get their IP automatically
Plug a laptop into Ethernet or join a Wi-Fi network and it magically gets an IP address, a subnet mask, a default gateway, and DNS servers. That magic is DHCP (Dynamic Host Configuration Protocol). Without DHCP, every device on your network would need a manually assigned static IP — and you'd have to track them yourself.
The DORA dance
DHCP is a four-step conversation, mnemonically DORA:
- Discover — "Hi, anyone here speak DHCP?" The new device broadcasts to
255.255.255.255because it doesn't have an IP yet. - Offer — The DHCP server (usually your router) replies: "Here, you can have
192.168.1.42, with this subnet mask, this gateway, these DNS servers." - Request — The device formally asks for that specific offer, in case multiple servers offered different addresses.
- Acknowledge — The server confirms: "It's yours. Lease expires in 24 hours."
Leases — IPs are rented, not given
An IP isn't yours forever. DHCP issues a lease for a configurable period (24 hours is common at home, much shorter on busy networks). Your device renews the lease in the background before it expires. If a device disappears, the IP eventually returns to the pool.
Reservations — predictable IPs without going static
Want a server to always get the same IP without configuring it manually? Use a DHCP reservation: tell the router "when you see MAC address aa:bb:cc:dd:ee:ff, always hand out 192.168.1.100." You get DHCP's auto-config plus a static IP's predictability. This is the right pattern for any machine you SSH into frequently.