DHCP — Dynamic Host Configuration Protocol — is what quietly hands a device its IP address, subnet mask, default gateway and DNS servers the moment it joins a network. Your router is almost certainly running a DHCP server right now, which is exactly why your phone and laptop get online without you ever typing in network settings.
Without DHCP, you'd configure every device by hand, and give two of them the same address and watch both drop offline. So here's how DHCP actually hands out addresses, what a lease really is, how reservations work, and the fixes for the DHCP errors you're most likely to run into.
What DHCP provides
DHCP for IPv4 lives in RFC 2131, and RFC 2132 lists every configuration option it's allowed to carry. A DHCP server does a lot more than just assign an address — here's what a typical reply from a home router actually contains:
| Setting | DHCP option | Example value |
|---|---|---|
| IP address | The yiaddr field | 192.168.1.57 |
| Subnet mask | Option 1 | 255.255.255.0 |
| Default gateway (router) | Option 3 | 192.168.1.1 |
| DNS servers | Option 6 | 192.168.1.1 or a public resolver |
| Domain name | Option 15 | home.example.com |
| Lease time | Option 51 | 86400 seconds (24 hours) |
Almost every address a DHCP server gives out is a private one, drawn from the RFC 1918 ranges. Not sure which kind you got? Our IP address type checker will tell you.
How DHCP works: the DORA process
DHCP rides on UDP — servers listen on port 67, clients on port 68. A brand-new device has no address yet, so its first messages go out as broadcasts. People usually remember the whole exchange with one word: DORA.
- Discover. The client fires off a DHCPDISCOVER from source
0.0.0.0to the broadcast address255.255.255.255, identifying itself with its MAC address. - Offer. Any DHCP server that hears the broadcast can reply with a DHCPOFFER, proposing an address plus options.
- Request. The client picks one offer and broadcasts a DHCPREQUEST naming the server it chose — broadcasting this step is what lets the other servers know their offers got turned down.
- Acknowledge. The chosen server confirms with a DHCPACK. From there, the client might double-check that nobody else is squatting on that address (an ARP probe, say) before configuring its interface.
A few other message types cover the edge cases. DHCPNAK refuses a request outright (say, a laptop asking to keep an address that belongs to a different network), DHCPDECLINE flags an offered address as already taken, and DHCPRELEASE hands an address back before the lease is even up.
DHCP relays on larger networks
Broadcasts don't cross routers, full stop. So a business network with a dozen subnets usually runs one central DHCP server and turns each router into a DHCP relay instead. The relay catches broadcasts on its local subnet, forwards them as unicast to the server, and tacks on the subnet's gateway address so the server knows which pool to draw from.
Leases and renewal
Think of a DHCP address as a lease, not a permanent grant. RFC 2131 builds in two timers tied to how long that lease runs:
- T1 (renewal) kicks in at 50% of the lease by default. The client goes straight back to the server that issued it and asks for an extension — which the server almost always grants, so the address stays put.
- T2 (rebinding) arrives at 87.5% by default. If the original server still hasn't answered by then, the client gives up on it and broadcasts to ask any server to extend the lease.
Let the lease expire without renewing, and the client has to drop the address and start over from Discover. That's why a device left plugged in tends to keep the same local address for months, while one that's been away longer than the lease time might come back to a completely different one. Run that same mechanism at your ISP, and you've got one reason your public address changes — more on that in our guide to static vs dynamic IP addresses.
The address pool
The server only hands out addresses from a configured range — a pool or scope — say 192.168.1.100 to 192.168.1.199. Anything outside that pool but still inside the subnet is left free for devices you'd rather configure by hand. Before picking a range, run it past the subnet calculator to see which addresses are actually valid on your network.
DHCP reservations vs static IPs
Printers, NAS boxes, game consoles, anything you're forwarding ports to — these all want an address that never moves. You've got two ways to pin one down:
- DHCP reservation (also called a static lease, or address binding). You tie a MAC address to an IP right in the router's DHCP settings. The device still goes through the DHCP dance, it just always lands on the same address — and things like DNS servers stay managed from one place.
- Manual static IP. You type the address, mask, gateway and DNS straight into the device itself. Just pick something outside the DHCP pool, or you'll end up with a conflict.
At home, reservations usually win — everything stays managed from one screen. They're also step one if you're setting up port forwarding.
Viewing and renewing your DHCP lease
Windows
ipconfig /all
ipconfig /release
ipconfig /renew
ipconfig /all tells you whether DHCP is even enabled, which server answered, and exactly when the lease was picked up and when it runs out. /release hands the address back, /renew asks for a fresh one — run both from an elevated Command Prompt.
macOS
ipconfig getpacket en0 # full DHCP response, including lease_time
sudo ipconfig set en0 DHCP # restarts DHCP on the interface
Linux
ip addr show # "dynamic" marks a DHCP address
nmcli connection down "Wired connection 1" && nmcli connection up "Wired connection 1"
sudo networkctl renew eth0 # on systemd-networkd systems
On a phone, just toggling Wi-Fi off and back on — or forgetting the network and rejoining — triggers a brand-new DHCP exchange.
Common DHCP problems and fixes
The device has a 169.254.x.x address
No DHCP server answers? Windows, macOS and most Linux setups will just assign themselves a link-local address out of 169.254.0.0/16 (RFC 3927) — Windows often adds the blunt message "unable to contact your DHCP server." A device stuck on one of these can only chat with its immediate neighbours, never the internet. Check the cable or the Wi-Fi association, restart the router, and confirm its DHCP server is actually switched on.
The pool is full
A house full of guests and smart-home gadgets can genuinely run the pool dry, especially with long lease times set. New devices join the Wi-Fi fine and then just... never get an address. Enlarge the pool, shorten the lease time, or clear out stale reservations.
IP address conflicts
Nine times out of ten, a conflict means somebody set a static IP inside the DHCP pool. Move that device outside the pool, or just convert it to a reservation instead.
Two DHCP servers on one network
Plug in a second router with DHCP still switched on, and congratulations — you've got a rogue DHCP server. Devices grab an address from whichever server answers first, and some end up pointed at the wrong gateway entirely. Turning a second router into an access point? Turn off its DHCP server first. On business networks, managed switches offer DHCP snooping, which blocks offers coming from untrusted ports before this can happen.
DHCP and IPv6
IPv6 hosts can actually configure themselves, using SLAAC from router advertisements, which makes DHCP optional here. DHCPv6 (RFC 8415) runs over UDP ports 546 and 547 and can assign addresses, hand out DNS servers, or delegate entire prefixes to routers. Plenty of ISPs lean on DHCPv6 prefix delegation to give your router an IPv6 prefix, while the devices on your LAN handle themselves via SLAAC. One catch: Android has historically skipped support for stateful DHCPv6 address assignment, so a network that relies on DHCPv6 alone for addresses leaves Android devices without IPv6 at all.
Frequently asked questions
Should I turn off DHCP on my router?
Only if something else on that network — a dedicated server, or a main router upstream — is already providing DHCP. Turn it off with nothing else covering for it, and every new device would need its settings typed in by hand.
Is DHCP a security risk?
DHCP was never built with authentication in mind, so anyone on your local network can spin up a rogue server or drain the pool by requesting a flood of addresses. At home that risk is pretty minor; on shared or business networks, DHCP snooping and port security on the switches are how you deal with it.
What lease time should I use?
For a home network, the usual default of around a day is perfectly fine. Guest networks and busy public Wi-Fi do better with shorter leases — one to four hours, say — so addresses from devices that have already left come back to the pool fast.
Does DHCP assign my public IP address?
More often than not, yes. Plenty of ISPs use DHCP to assign your router its WAN address, and that lease behaves exactly like the ones your own router hands out — which is exactly why your public IP can shift after a long outage or a modem swap.
Yorumlar
Bir ipucu paylaşın, soru sorun ya da aracın işinize nasıl yaradığını anlatın.