Automatic IP Configuration
When your device connects to a network, it needs an IP address, subnet mask, default gateway, and DNS server information. DHCP (Dynamic Host Configuration Protocol) provides all of this automatically โ no manual configuration required.
Without DHCP, you'd have to manually configure every device on every network you join. Imagine typing IP addresses every time you connect to a new Wi-Fi network. DHCP makes networking plug-and-play.
How DHCP Works (DORA Process)
DHCP uses a four-step process called DORA:
Client DHCP Server
โ โ
โโโโโ 1. DHCP Discover โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (broadcast: "Is there a DHCP server?") โ
โ โ
โโโโโ 2. DHCP Offer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ("Yes! Here's an IP: 192.168.1.100") โ
โ โ
โโโโโ 3. DHCP Request โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ("I'll take 192.168.1.100") โ
โ โ
โโโโโ 4. DHCP Acknowledgment โโโโโโโโโโโโโโโโโโโโ
โ ("Confirmed! Use it for 24 hours") โ
After this process, the client has:
- An IP address
- A subnet mask
- A default gateway
- DNS server addresses
- A lease time (how long the IP is valid)
DHCP Lease and Renewal
DHCP addresses are leased, not permanently assigned. The lease has an expiration time (typically 24 hours). The client must renew the lease before it expires:
Lease obtained โโโโ 50% elapsed โโโโ 87.5% elapsed โโโโ Lease expires
โ โ โ โ
โ โ โ โ
โ T1: Try to T2: Try to Lose address
โ renew with renew with any (must DORA again)
โ original server DHCP server
If the client can't renew before the lease expires, it must release the address and go through the DORA process again.
DHCP in Home Networks
Your home router is almost certainly running a DHCP server. When your phone or laptop connects to Wi-Fi, the router:
- Assigns a private IP address (like 192.168.1.100)
- Tells the device its own IP is the default gateway (192.168.1.1)
- Provides DNS server addresses (often its own or the ISP's)
This is why you can connect to any Wi-Fi network and it "just works" โ DHCP handles all the configuration automatically.
APIPA: The Fallback
If DHCP fails (no server available, network issues), most operating systems assign an APIPA (Automatic Private IP Addressing) address in the range 169.254.x.x. This allows devices on the same network to communicate locally, even without a DHCP server. But they won't have internet access.