DHCP (Dynamic Host Configuration Protocol) is how a device joining a network gets its IP address, subnet mask, default gateway and DNS servers automatically from a server, usually your router. The device broadcasts a request, the server offers an address from its pool, and the device keeps it on a timed lease that it renews in the background.
Without DHCP you would type those four settings into every phone, laptop and TV by hand, and keep track of which addresses were already taken.
How DHCP works: the DORA exchange
RFC 2131 defines a four-message exchange, often remembered as DORA. The new device has no IP address yet, so it starts by broadcasting:
- Discover. The client broadcasts a
DHCPDISCOVERto 255.255.255.255. With no address of its own, it uses 0.0.0.0 as the source. - Offer. Each DHCP server that hears it replies with a
DHCPOFFER: a proposed IP address plus options such as mask, gateway and lease time. - Request. The client picks one offer and broadcasts a
DHCPREQUESTnaming that server. Servers that weren't chosen "use the message as notification that the client has declined that server's offer." - Acknowledge. The chosen server confirms with a
DHCPACK. The client can now use the address.
All of this runs over UDP. Clients send to the "DHCP server" port 67, and servers reply to the client port 68. RFC 2131 also says the client should check that the address isn't already in use, for example with an ARP request, and if it is, the client "MUST send a DHCPDECLINE message to the server" and start again.
All DHCP message types
RFC 2132 numbers the message types (carried in option 53):
| Value | Message | Sent by | Purpose |
|---|---|---|---|
| 1 | DHCPDISCOVER | Client | Find servers |
| 2 | DHCPOFFER | Server | Propose an address |
| 3 | DHCPREQUEST | Client | Accept an offer, or renew a lease |
| 4 | DHCPDECLINE | Client | Address is already in use |
| 5 | DHCPACK | Server | Confirm |
| 6 | DHCPNAK | Server | Refuse (address no longer valid) |
| 7 | DHCPRELEASE | Client | Give the address back |
| 8 | DHCPINFORM | Client | Ask for options only (address already configured) |
What a DHCP server hands out
The address is only part of it. The rest travels as numbered options, defined in RFC 2132:
| Option | Name | Example value |
|---|---|---|
| 1 | Subnet Mask | 255.255.255.0 |
| 3 | Router (default gateway) | 192.168.1.1 |
| 6 | Domain Name Server | 192.168.1.1 |
| 15 | Domain Name | home.arpa |
| 51 | IP Address Lease Time | 86400 seconds (24 hours) |
| 54 | Server Identifier | 192.168.1.1 |
| 58 / 59 | Renewal (T1) / Rebinding (T2) Time | 43200 / 75600 seconds |
On a home network the router is usually all of these at once: DHCP server, gateway and DNS forwarder. That's why the same address appears in several rows.
DHCP leases and renewal
An address is leased, not given. RFC 2131 sets two timers, unless the server sends its own values:
- T1 = 0.5 × lease. At half the lease the client enters the RENEWING state and "sends (via unicast) a DHCPREQUEST message" to the server that gave it the address.
- T2 = 0.875 × lease. If that server hasn't answered by 87.5% of the lease, the client enters REBINDING and broadcasts the request so any server can extend it.
Worked example with a 24-hour lease: renewal starts at 12 hours, rebinding at 21 hours, and if the lease runs out at 24 hours without a reply, RFC 2131 says the client "must immediately discontinue use of the previous network address" and start over. On a healthy network the renewal at 12 hours succeeds and you never notice. The address usually stays the same, since the client asks to keep it.
How to see your DHCP lease on Windows
ipconfig /all
Look for your active adapter. Example output (addresses changed):
DHCP Enabled. . . . . . . . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.37(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Monday, 26 October 2026 10:55:28
Lease Expires . . . . . . . . . . : Tuesday, 27 October 2026 10:55:28
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 192.168.1.1
DHCP Enabled: Yes confirms the adapter uses DHCP. The two lease lines show the lease length; here, 24 hours. The date format follows your Windows region settings.
How to renew or release a DHCP address
On Windows, in Command Prompt or PowerShell:
ipconfig /release
ipconfig /renew
Microsoft's documentation says /release "sends a DHCPRELEASE message to the DHCP server" and discards the address, and /renew renews the DHCP configuration. Both act on every adapter unless you name one, for example ipconfig /renew "Wi-Fi". Use /release6 and /renew6 for DHCPv6. Running /release drops your connection until /renew completes, so don't run it over a remote desktop session.
On a Mac, Apple's steps are: Apple menu > System Settings > Network in the sidebar, select the network service, click Details, select TCP/IP, click Renew DHCP Lease, then OK.
On Linux the command depends on which network manager the distribution uses (NetworkManager, systemd-networkd or another client), so check your distribution's documentation. Reconnecting the interface triggers a fresh DHCP exchange with any of them.
DHCP across subnets: relay agents
A DHCP Discover is a broadcast, and routers don't forward broadcasts. In offices with many subnets, one central server serves them all through relay agents. RFC 2131 defines a relay agent as "an Internet host or router that passes DHCP messages between DHCP clients and DHCP servers". In practice that's usually a setting on the router interface for each subnet; the name of the setting varies by vendor.
When DHCP fails: the 169.254 address
If no server answers, many operating systems give themselves an IPv4 link-local address. RFC 3927 reserves 169.254.0.0/16 for this and has hosts pick from 169.254.1.0 to 169.254.254.255. Windows calls this Automatic Private IP Addressing (APIPA). Seeing one means "DHCP didn't work", not "the internet is down". Things to check, in order:
- The physical link: cable, Wi-Fi association, the right Wi-Fi network.
- That the router's DHCP server is enabled and the pool isn't exhausted (a /24 pool has at most 254 addresses, often fewer if the range is narrower).
- Then renew the lease with the commands above.
For more on why the address you get starts with 192.168 or 10, see public vs private IP addresses; for what a /24 is, see CIDR notation explained. If you get an address but names won't resolve, the DNS server your DHCP lease handed out is the next thing to check: how DNS works.
Frequently asked questions
- What is the difference between DHCP and a static IP?
- With DHCP the device asks the network for an address each time it connects and gets one from a pool, on a timed lease. With a static IP you type the address, mask, gateway and DNS servers into the device yourself, and it never asks. Most routers also offer a DHCP reservation, which hands the same address to the same device every time while keeping the settings managed centrally.
- What does a 169.254.x.x address mean?
- It means the device asked for an address and no DHCP server answered, so it gave itself an IPv4 link-local address from 169.254.0.0/16 (RFC 3927). It can talk to other devices on the same link but not reach the internet. Check the cable or Wi-Fi connection and that the router's DHCP server is on, then renew the lease.
- Is DHCP secure?
- Not by itself. RFC 2131's own security section says DHCP 'in its current form is quite insecure' and that 'unauthorized DHCP servers may be easily set up'. A rogue server, whether a spare home router plugged into an office network or a deliberate attack, can hand out duplicate addresses or a fake gateway or DNS server. Protection has to come from the network, for example switches that only accept DHCP answers from trusted ports.
- How long is a DHCP lease?
- Whatever the server is configured to offer; the protocol doesn't fix a value. The server sends it as option 51, IP Address Lease Time. You can see your current lease on Windows in the Lease Obtained and Lease Expires lines of ipconfig /all.