How DHCP Works: Discover, Offer, Request, Renewals, Relays and Snooping
The DHCP exchange step by step, captured from a Kea server: DISCOVER, OFFER, REQUEST and ACK, the client states, renewing and rebinding with a short lease, RELEASE, INFORM and NAK, then relay agents and option 82, rapid commit, FORCERENEW, authentication, and DHCP snooping against rogue servers.
kvi5hnuCode Sprout team member17 min readOn this page
Article 29 described what DHCP carries. This one shows how a client and server talk: the four-message exchange that gets a lease, what happens when the lease needs renewing or the server disappears, how one server can serve many subnets through relay agents, and how switches stop a stray server from taking over a network. All the captures come from a lab with a Kea server and the ISC dhclient client.
The four-message exchange

The diagram shows the whole life of a lease: the first four messages get it, and the lower part (renewing at T1, rebinding at T2) is covered later in this article. Getting a new lease takes four messages, often remembered as DORA:
- DISCOVER. The client broadcasts, asking for any server to answer. It may include option 50 to ask for an address it used before.
- OFFER. Each server that's willing to serve the client picks an address and sends an offer, with the address in
yiaddrand the options the client asked for. The server should reserve that address for a short while. - REQUEST. The client picks one offer and broadcasts a REQUEST that names the chosen server in option 54 (Server Identifier) and the address in option 50 (Requested IP Address). Because it's broadcast, every server that made an offer sees it, and those not chosen release the addresses they'd reserved.
- ACK. The chosen server confirms the lease. The client may now use the address.
Here is the exchange in the lab, then the client giving the address back (RELEASE) and getting a lease again, and finally an INFORM. Each line gives the time in seconds, the IP source and destination, the message type and the three address fields from article 29:
0.000 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.001 192.0.2.2 -> 192.0.2.100 OFFER ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
0.001 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.001 192.0.2.2 -> 192.0.2.100 ACK ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
1.537 192.0.2.100 -> 192.0.2.2 RELEASE ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
2.101 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
2.101 192.0.2.2 -> 192.0.2.100 OFFER ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
2.101 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
2.103 192.0.2.2 -> 192.0.2.100 ACK ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
2.419 192.0.2.100 -> 255.255.255.255 INFORM ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
2.420 192.0.2.2 -> 192.0.2.100 ACK ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
The DISCOVER, seen at the link and transport layers:
Ethernet 02:00:00:00:0c:01 -> ff:ff:ff:ff:ff:ff
IP 0.0.0.0 -> 255.255.255.255
UDP 68 -> 67
broadcast flag False
With no address, the client sends from 0.0.0.0 to the broadcast address 255.255.255.255, and to the broadcast Ethernet address, from client port 68 to server port 67. The broadcast flag is off, which tells the server it may reply by unicast to the offered address, as Kea did. The REQUEST carries the two options that pin down the choice:
Option: (54) DHCP Server Identifier (192.0.2.2)
Option: (50) Requested IP Address (192.0.2.100)
Two more details from the capture:
- The REQUEST's
ciaddris0.0.0.0. The client doesn't own the address until the ACK arrives, so it doesn't use it yet. - The transaction ID (
xid) is the same in all four messages of one exchange, and different in the next. That's how a client knows which replies are answers to its question.
Before using the address: checking for conflicts
A client should make sure nobody else is using the address before it starts using it. RFC 2131 says it should check, typically with ARP. The modern method is Address Conflict Detection (RFC 5227, article 22): the client sends ARP probes for the address and listens for an answer. If another machine answers, the client sends a DECLINE to the server, which marks the address as unusable for a while, and the client starts over with DISCOVER. Servers can check too, by pinging an address before offering it. Kea does this with an optional hook.
Client states
A DHCP client moves through a small set of states, defined in RFC 2131:
| State | What the client is doing |
|---|---|
| INIT | No lease: sends DISCOVER |
| SELECTING | Collecting OFFERs |
| REQUESTING | Sent REQUEST, waiting for ACK or NAK |
| BOUND | Has a valid lease and uses the address |
| RENEWING | Past T1: unicasts REQUEST to its own server |
| REBINDING | Past T2: broadcasts REQUEST to any server |
| INIT-REBOOT | Restarting with a remembered lease |
| REBOOTING | Sent REQUEST for the remembered address, waiting |
INIT-REBOOT and NAK
A client that restarts, or reconnects to a network, and still holds an unexpired lease doesn't need to go through DORA. It broadcasts a REQUEST for its old address straight away (INIT-REBOOT), without option 54, since it isn't choosing between servers. If the address is still valid for this network, the server ACKs it.
If the client has moved to a different network, the address is wrong there. An authoritative server, one configured to know it's responsible for the network, answers with a NAK, and the client returns to INIT. The lab moved the client to a network served by a different Kea server for 203.0.113.0/24:
0.000 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.002 203.0.113.2 -> 255.255.255.255 NAK ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.009 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.009 203.0.113.2 -> 203.0.113.100 OFFER ciaddr 0.0.0.0 yiaddr 203.0.113.100 giaddr 0.0.0.0
0.009 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.010 203.0.113.2 -> 203.0.113.100 ACK ciaddr 0.0.0.0 yiaddr 203.0.113.100 giaddr 0.0.0.0
The REQUEST asked for the remembered address, and the NAK came from the new network's server:
Option: (50) Requested IP Address (192.0.2.100)
Option: (54) DHCP Server Identifier (203.0.113.2)
Within 20 milliseconds the client had sent a DISCOVER and got an address on the new network:
eth0@if11 203.0.113.100/24
A non-authoritative server stays silent when it doesn't know a client's address, so a client would wait for its REQUEST to time out before starting over. Kea is non-authoritative by default; the lab turned the setting on for this test.
RELEASE and INFORM
A client that's leaving may send a RELEASE by unicast to its server, giving the address back before the lease ends. That's polite but optional, and many clients don't bother: a laptop that's suspended or walks out of Wi-Fi range has no chance to.
A host whose address was set by hand can still get the other settings, such as DNS servers, by sending an INFORM with its address in ciaddr. The server replies with an ACK that carries options but has yiaddr set to 0 and no lease. The lab sent one with Scapy, and it's the last exchange in the capture above.
Renewing and rebinding
To keep its address, the client must renew its lease. The lab used a 40-second lease with T1 at 10 seconds and T2 at 25 seconds, and stopped the server just after the first renewal:
0.000 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.001 192.0.2.2 -> 192.0.2.100 OFFER ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
0.001 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.001 192.0.2.2 -> 192.0.2.100 ACK ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 0.0.0.0
9.201 192.0.2.100 -> 192.0.2.2 REQUEST ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
9.203 192.0.2.2 -> 192.0.2.100 ACK ciaddr 192.0.2.100 yiaddr 192.0.2.100 giaddr 0.0.0.0
19.164 192.0.2.100 -> 192.0.2.2 REQUEST ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
26.312 192.0.2.100 -> 192.0.2.2 REQUEST ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
35.199 192.0.2.100 -> 255.255.255.255 REQUEST ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
46.298 192.0.2.100 -> 255.255.255.255 REQUEST ciaddr 192.0.2.100 yiaddr 0.0.0.0 giaddr 0.0.0.0
49.457 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
57.966 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
Reading the timeline:
- 0 s: the normal DORA exchange gives a 40-second lease.
- 9.2 s: at about T1 (the client added some jitter), it unicasts a REQUEST from its own address to the server, with
ciaddrfilled in. The server ACKs, and the lease starts again from that moment. - The server stops. At the next T1, around 19 s, the client sends a unicast REQUEST and gets no answer. It retries, with growing intervals, while in the RENEWING state.
- 35.2 s: past T2, the client gives up on its own server and broadcasts the REQUEST (REBINDING), hoping another server can extend the lease. Still nothing.
- 49.5 s: the lease, which started at 9.2 s, has expired. The client must stop using the address. It goes back to INIT and broadcasts DISCOVER.
If a second server had been running and knew about the lease, for example the partner in a Kea high-availability pair, it would have answered the broadcast at step 4 and the client would never have noticed anything.
Relay agents
Broadcasts don't cross routers, so a DHCP server could only serve clients on its own link. Large networks have hundreds of subnets and don't want a server on each. A relay agent, usually a function of the router on each subnet, forwards DHCP messages to central servers:

The lab put the client on 192.0.2.0/24, the server on 198.51.100.0/24, and ran dnsmasq as a relay on the router between them. The first capture is on the client's side of the relay, the second on the server's side, and the third shows details of one relayed DISCOVER:
0.000 0.0.0.0 -> 255.255.255.255 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.002 192.0.2.1 -> 192.0.2.100 OFFER ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 192.0.2.1
0.002 0.0.0.0 -> 255.255.255.255 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 0.0.0.0
0.002 192.0.2.1 -> 192.0.2.100 ACK ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 192.0.2.1
0.000 192.0.2.1 -> 198.51.100.2 DISCOVER ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 192.0.2.1
0.001 198.51.100.2 -> 192.0.2.1 OFFER ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 192.0.2.1
0.002 192.0.2.1 -> 198.51.100.2 REQUEST ciaddr 0.0.0.0 yiaddr 0.0.0.0 giaddr 192.0.2.1
0.002 198.51.100.2 -> 192.0.2.1 ACK ciaddr 0.0.0.0 yiaddr 192.0.2.100 giaddr 192.0.2.1
IP 192.0.2.1 -> 198.51.100.2, UDP 67 -> 67
hops 1, giaddr 192.0.2.1, chaddr 02:00:00:00:0c:01
What the relay does:
- It puts the address of the interface the request arrived on into giaddr. The server uses giaddr to decide which subnet the client is on, here
192.0.2.0/24, though the server itself has no interface on that subnet. - It increments hops, so relays can drop messages that have looped too many times.
- It sends the message by unicast to the configured server address, from port 67 to port 67.
- Replies come back to the relay at giaddr, and the relay delivers them to the client on the LAN, by broadcast or unicast as the flags ask.
On Cisco-style routers this is the ip helper-address command, and on Linux, where Kea has no relay of its own, a separate program such as dnsmasq (as here) or ISC's older dhcrelay does the job. The client ended up with an address from the remote server's pool:
eth0@if11 192.0.2.100/24
Option 82: Relay Agent Information
A relay can add option 82 (RFC 3046) to tell the server more about where the client is. It has sub-options such as Circuit ID (often the switch and port the client is plugged into) and Remote ID (often the switch's identity, or a subscriber line on a DSL or cable network). The server can use them to choose addresses or policies, for example one address per port. The relay removes option 82 from the server's reply before passing it on, so the client never sees it.
Other DHCP features
- Rapid Commit (option 80, RFC 4039). A client that includes it in its DISCOVER tells servers that a two-message exchange is fine: a server supporting it replies directly with an ACK, skipping OFFER and REQUEST. It suits networks with a single server, where there's no choice to make.
- FORCERENEW (RFC 3203). A server-to-client message that tells the client to renew immediately, so the server can push new settings or renumber the network. Since anyone could send one, RFC 3203 requires authentication, and RFC 6704 adds a method based on a nonce (a one-time random value) to make it practical. It's rarely deployed.
- Authentication (RFC 3118). An option that lets clients and servers sign messages with shared keys. It was hard to manage keys for every client, and it's essentially unused. In practice, DHCP is secured by controlling the network, as in the next section.
- Location information. Options carry the client's location for emergency calls: geospatial coordinates (RFC 6225) or a civic address (RFC 4776). They mostly matter for VoIP (voice over IP) phones in enterprises.
- Mobility and network access information. Options exist to tell clients about mobility servers (RFC 5678) and network access authentication agents (PANA, the Protocol for carrying Authentication for Network Access, RFC 5192). Like Mobile IP itself (article 28), these are little used.
DHCP snooping
Anyone on a network can run a DHCP server, by accident (a home router plugged in backwards) or on purpose (an attacker). A rogue server that answers faster than the real one can give clients a wrong default router or DNS server, sending their traffic through the attacker (article 33).
The lab put a client, the real server and a rogue server on the same switch, modeled with a Linux bridge. The rogue offers addresses from .200 up and names itself as the router:
OFFER from 192.0.2.66: address 192.0.2.200, router 192.0.2.66
OFFER from 192.0.2.2: address 192.0.2.100, router 192.0.2.1
client took 192.0.2.200/24
Both servers answered, and the client took the offer that arrived first. In this run that was the rogue's, so the client's default router is now the attacker's machine at 192.0.2.66. On another run the real server may win the race, which is exactly the problem: nothing in DHCP lets the client tell the two apart.
Managed switches defend against this with DHCP snooping. Ports are marked trusted (those leading to real servers or uplinks) or untrusted (everything else), and the switch drops server messages (OFFER, ACK, NAK) arriving on untrusted ports. The lab emulated the core of that with a bridge firewall rule that drops anything from UDP port 67 unless it comes in on the real server's port ps:
iifname != "ps" udp sport 67 counter packets 0 bytes 0 drop
OFFER from 192.0.2.2: address 192.0.2.101, router 192.0.2.1
client took 192.0.2.101/24
counter packets 1
The rogue's offer was dropped, as the counter shows, and the client only ever saw the real server.
Real snooping does more:
- The switch records which IP address was leased to which MAC address on which port, in a binding table.
- Dynamic ARP Inspection uses the table to drop ARP replies that don't match a binding, stopping ARP spoofing (article 22).
- IP Source Guard uses it to drop IP packets from a port whose source address doesn't match the lease, stopping address spoofing.
- Switches can also rate-limit DHCP messages on untrusted ports, so a client can't exhaust the server's pool with floods of DISCOVERs using fake MAC addresses (a starvation attack, article 33).
Common questions
Why does the client broadcast its REQUEST instead of sending it to the server it chose?
So that every server that made an offer learns the decision. The servers that weren't chosen see a REQUEST naming another server in option 54 and release the address they'd set aside. And since the client doesn't own an address yet, it couldn't receive an ordinary unicast reply anyway unless the server cooperates.
What does a client do if no server answers its DISCOVER?
It retransmits. RFC 2131 suggests waiting about 4 seconds before the first retry and doubling the wait each time up to 64 seconds, with a second of random variation either way (the interval 4 in article 29's dhclient log is the first of these waits). Many clients eventually give up for a while and, on IPv4, may fall back to a link-local 169.254.x.x address (article 32) so they can at least talk on the local link.
What happens if the DHCP server is down when my lease expires?
The client stops using the address and starts again with DISCOVER, repeating until a server answers. Existing connections break. That's why critical networks run two servers that share lease state (Kea's high-availability mode or a similar setup), and why longer leases give more time to fix a server.
Does a laptop renew its lease every time it wakes up?
Usually it does something close to that. When it reconnects, a client with an unexpired lease sends an INIT-REBOOT REQUEST for the same address, or first checks with RFC 4436-style probes whether it's on the same network. If it's on a different network, an authoritative server answers with NAK and the client starts over.
How does the server know which subnet a relayed client is on?
From giaddr, the relay's address on the client's subnet. The server looks for a configured subnet containing that address, and allocates from its pool. Some setups use option 82 or the link selection sub-option (RFC 3527) instead, when giaddr can't be an address on the client's subnet.
Can DHCP messages be encrypted?
Not in DHCPv4. Messages are sent in the clear, and authentication (RFC 3118) is almost never used. Protection comes from the network: DHCP snooping on switches, and port security or 802.1X (article 81) to control who can plug in.
What is a DHCP "lease time" of infinity?
The value 0xFFFFFFFF in option 51 means the lease never expires. Servers rarely use it for dynamic clients, but it's how some BOOTP-style permanent assignments are represented.
Summary
- DORA: the client broadcasts DISCOVER, servers OFFER, the client broadcasts a REQUEST naming its choice (options 54 and 50), and the chosen server ACKs. All four share one transaction ID.
- Clients should check an address with ARP (RFC 5227) before using it, and DECLINE it if it's taken.
- A client with a remembered lease skips straight to REQUEST (INIT-REBOOT). An authoritative server NAKs an address that's wrong for the network.
- RELEASE returns an address early. INFORM gets options for a manually configured address.
- At T1 the client renews by unicast with its server; at T2 it rebinds by broadcast with any server; at expiry it stops using the address and starts over.
- Relay agents set giaddr and hops and unicast to central servers, which choose the subnet from giaddr. Option 82 tells the server the client's port or line.
- Rapid Commit shortens the exchange to two messages. FORCERENEW, authentication and location options exist but are little used.
- DHCP snooping on switches drops server messages from untrusted ports, defeating rogue servers, and its binding table drives ARP inspection and IP source guard.
Practice questions
1. In a DORA exchange, which messages are normally broadcast and which can be unicast?
Answer
DISCOVER and REQUEST from the client are broadcast, because the client has no address yet and the REQUEST must reach all servers that made offers. OFFER and ACK can be unicast to the offered address and the client's MAC address, unless the client set the broadcast flag, in which case they're broadcast.
2. A client's REQUEST contains option 54 = 192.0.2.2. A second server, 192.0.2.3, also made an offer. What does 192.0.2.3 do when it sees the REQUEST?
Answer
It sees that the client chose another server, so it returns the address it had reserved for the client to its pool and does nothing else.
3. A client got a lease of 1 hour at 10, with default timers. Its server crashes at 10 and a second server that shares lease state stays up. What messages does the client send, and when?
Answer
At about 10 (T1) it unicasts a REQUEST to the crashed server and gets no answer, and keeps retrying. At about 10:52 (T2) it broadcasts a REQUEST. The second server, which knows the lease, ACKs it and extends the lease. The client keeps its address without interruption.
4. A relay agent at 198.51.100.1 forwards a DISCOVER from a client on 198.51.100.0/24 to a server at 203.0.113.5. What values do giaddr and hops have in the forwarded message, and where does the server send its OFFER?
Answer
giaddr = 198.51.100.1 and hops = 1 (assuming no relay before it). The server sends the OFFER to the relay at 198.51.100.1, port 67, and the relay delivers it to the client on the LAN.
5. A user plugs a home Wi-Fi router into an office network, LAN port to LAN port. Some colleagues lose Internet access. Why, and what switch feature prevents it?
Answer
The home router runs a DHCP server and starts answering DISCOVERs on the office network, giving out its own addresses, default router and DNS server, which don't lead anywhere useful. Clients that take its offers lose connectivity. DHCP snooping, with that port untrusted, would drop the home router's OFFERs and ACKs.
6. What is the difference between a NAK and a DECLINE?
Answer
A NAK is sent by a server to a client, refusing its REQUEST because the address is wrong for the network or no longer available. A DECLINE is sent by a client to a server after it receives an address that turns out to be in use by another machine (found with ARP), so the server marks it as unusable.
Previous: DHCP Basics: Leases, Address Pools, the Message Format and Options
Next: DHCPv6: Stateful and Stateless Configuration and Prefix Delegation

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.