Sub topic 5
Discover, Offer, Request, Acknowledge step by step
This chapter assumes you know IPv4 addresses and subnet masks, what a default gateway and DNS server do, and that DHCP clients talk over UDP ports 68 (client) and 67 (server) using broadcast. Here you follow the four-message exchange a client uses to get its first address.
The four messages
A client with no address starts the exchange. Every message carries a transaction ID (xid) chosen by the client, so the client can match replies to its own request. The messages are often called DORA, after their first letters.
| Step | Message | Sent by | Source IP | Destination IP |
|---|---|---|---|---|
| 1 | Discover | Client | 0.0.0.0 | 255.255.255.255 |
| 2 | Offer | Server | Server's IP | 255.255.255.255 or the offered IP (unicast) |
| 3 | Request | Client | 0.0.0.0 | 255.255.255.255 |
| 4 | Acknowledge (ACK) | Server | Server's IP | 255.255.255.255 or the offered IP (unicast) |
Step 1: Discover
The client has no address, so it uses 0.0.0.0 as the source and broadcasts to 255.255.255.255. It may ask for a specific address or lease time, but the server is free to ignore that. The message also carries the client's MAC address and a list of options it wants (parameter request list).
Step 2: Offer
Each server that has a free address in a suitable scope replies with an Offer. The Offer contains:
- the proposed address in the
yiaddrfield ("your IP address"), - the subnet mask, lease time and other options,
- the server identifier, which is the server's own IP address.
The server holds the offered address for a short time so it does not give it to someone else. Because the client has no address yet, the server may broadcast the Offer or unicast it to the client's MAC address. The client sets a "broadcast flag" in the Discover to say which it can accept.
Step 3: Request
The client may receive several Offers. It usually picks the first one. It then broadcasts a Request that includes the server identifier of the chosen server and the address it wants. The broadcast is deliberate. Every server hears the Request, and the servers that were not chosen see another server's identifier and release their held addresses.
Step 4: Acknowledge
The chosen server records the lease and sends an ACK with the final options. Only now does the client configure its interface with the address, mask, router and DNS server. Many clients also probe the address with ARP first to check that no other host uses it. If the address is taken, the client sends a Decline and starts again (covered in a later chapter).
Watching it happen
Capture the exchange with this command, then release and renew the lease in another terminal.
sudo tcpdump -n -i eth0 -vv 'udp and (port 67 or port 68)'In the output, check that all four packets share the same transaction ID. Look in the Offer for Server-ID, Lease-Time and Subnet-Mask.
Common mistakes
- Seeing a Discover but no Offer usually means the server is unreachable, has no free addresses, or the request needs a relay agent.
- Assuming the Offer assigns the address. It only proposes it. The address belongs to the client after the ACK.
- Forgetting that the Request is broadcast, even though the client already knows which server it chose.
Exercise
A client broadcasts a Discover and two servers reply with Offers. The client sends a Request naming Server A. What happens to the address that Server B offered, and why is the Request broadcast?
Show answer
Server B sees Server A's identifier in the Request, understands its offer was declined, and releases the address it held. The Request is broadcast so that every server hears it, not only the chosen one.
Exercise
In a tcpdump capture you see Discover and Offer packets but no Request. At which step did the exchange stop, and what might the client be doing?
Show answer
It stopped after step 2, so the client received the Offer but did not accept it. The client may have ignored it because the transaction ID did not match, or it may have chosen another server's Offer. If it never picked any Offer, the Offer may have been filtered or dropped on the way to the client.