The initial lease exchange
On this page
A device with no address must ask for one. It cannot identify itself by an assigned IPv4 address, and it does not know which server to ask. Start a listener before tablet joins. The first messages solve both problems without a manual address.
Before you start
Section titled “Before you start”Finish Why DHCP exists and remove its manual settings using its cleanup replay. Keep mode dhcp on and other modes off. Open two terminals using netlab shell tablet in each. Both prompts must name tablet. If you have already joined by DHCP, use the release steps in Try it yourself before repeating this fresh join.
Listen before the client starts
Section titled “Listen before the client starts”In terminal 1 run sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:'. DHCP uses UDP server port 67 and client port 68. Type your Ubuntu password when asked. The -l option prints each line at once so grep receives it while the capture runs. The grep -E command keeps address lines, message types, and Server Identifier values from the verbose output.
In terminal 2 run sudo dhcpcd -4 eth0. The program is the DHCP client; -4 selects IPv4 and eth0 names its interface. It returns to the prompt after obtaining configuration, leaving a client running. Read ip -4 address show eth0 and ip route there.
Predict: What source address can a device use before it has an address?
A fresh DHCP join
- tablet
- router
- phone
- Discover: tablet to router and phone
- Offer: router to tablet
- Request: tablet to router and phone
- Acknowledge: router to tablet
In the capture4 messages at tablet:eth0
- 1. Discover
12:20:43.366421 02:77:10:00:01:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 385: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343 - 2. Offer
12:20:46.372030 02:77:10:00:00:01 > 02:77:10:00:01:00, ethertype IPv4 (0x0800), length 344: 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302 - 3. Request
12:20:46.372426 02:77:10:00:01:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 394: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352 - 4. Acknowledge
12:20:46.380929 02:77:10:00:00:01 > 02:77:10:00:01:00, ethertype IPv4 (0x0800), length 344: 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302
sudo dhcpcd -4 eth0, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's. One fresh join, with each message's IPv4 addresses and Ethernet destination.Steps (4)
- Discover. tablet to router and phone. Tablet has no IPv4 address and asks the local network for settings.
12:20:43.366421 02:77:10:00:01:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 385: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343 - Offer. router to tablet. Router offers settings to tablet. This captured offer is unicast.
12:20:46.372030 02:77:10:00:00:01 > 02:77:10:00:01:00, ethertype IPv4 (0x0800), length 344: 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302 - Request. tablet to router and phone. Tablet broadcasts its choice.
12:20:46.372426 02:77:10:00:01:00 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 394: 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352 - Acknowledge. router to tablet. Router confirms the lease to tablet.
12:20:46.380929 02:77:10:00:00:01 > 02:77:10:00:01:00, ethertype IPv4 (0x0800), length 344: 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302
Check your answer
The Discover uses 0.0.0.0. Its destination is 255.255.255.255, the local broadcast address. It asks before tablet has its assigned address.
Read the four messages as one agreement
Section titled “Read the four messages as one agreement”A lease is permission to use an address for a limited time. It is not permanent ownership. This fresh join uses four messages to agree on a lease. A broadcast reaches every machine on the home network, including laptop; the stage shows phone as one example.
Discover asks for available configuration. Offer proposes configuration. Request asks to take an offered lease. Acknowledge confirms it; tcpdump calls that confirmation ACK. This DHCP acknowledgment is an application message, rather than the TCP acknowledgment flag from the previous module.
| Message | From | To | What it carries |
|---|---|---|---|
| Discover | Tablet: 0.0.0.0 |
Broadcast: 255.255.255.255 |
A search for configuration |
| Offer | Router: 10.77.10.1 |
Tablet: 10.77.10.105 |
Proposed lease |
| Request | Tablet: 0.0.0.0 |
Broadcast: 255.255.255.255 |
The selected offer |
| Acknowledge | Router: 10.77.10.1 |
Tablet: 10.77.10.105 |
Confirmed lease |
The Offer reaches tablet before it has the offered IPv4 address because the frame is sent to tablet’s MAC address. In this capture both server replies are unicast. Compare their Ethernet destination with the all-ones destination of Discover and Request. Do not turn the first broadcast into a rule that every message must be broadcast.
| Messages | Ethernet destination |
|---|---|
| Discover and Request | ff:ff:ff:ff:ff:ff, everyone on this network |
| Offer and Acknowledge | 02:77:10:00:01:00, tablet |
learner@tablet:~$ sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:'[sudo] password for learner: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343, xid 0xda1102a0, Flags [none]
DHCP-Message (53), length 1: Discover
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0xda1102a0, Flags [none]
DHCP-Message (53), length 1: Offer
Server-ID (54), length 4: 10.77.10.1
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352, xid 0xda1102a0, secs 3, Flags [none]
DHCP-Message (53), length 1: Request
Server-ID (54), length 4: 10.77.10.1
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0xda1102a0, secs 3, Flags [none]
DHCP-Message (53), length 1: ACK
Server-ID (54), length 4: 10.77.10.1^C4 packets captured
4 packets received by filter
0 packets dropped by kernellearner@tablet:~$ Steps (10)
- Type
sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:' - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343, xid 0xda1102a0, Flags [none] DHCP-Message (53), length 1: Discover 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0xda1102a0, Flags [none] DHCP-Message (53), length 1: Offer Server-ID (54), length 4: 10.77.10.1 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352, xid 0xda1102a0, secs 3, Flags [none] DHCP-Message (53), length 1: Request Server-ID (54), length 4: 10.77.10.1 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0xda1102a0, secs 3, Flags [none] DHCP-Message (53), length 1: ACK Server-ID (54), length 4: 10.77.10.1 - Press Ctrl + C
- Output:
4 packets captured 4 packets received by filter 0 packets dropped by kernel
learner@tablet:~$ sudo dhcpcd -4 eth0[sudo] password for learner: dhcpcd-10.0.6 starting
network namespace: tablet
eth0: soliciting a DHCP lease
eth0: offered 10.77.10.105 from 10.77.10.1
eth0: probing address 10.77.10.105/24
eth0: leased 10.77.10.105 for 43200 seconds
eth0: adding route to 10.77.10.0/24
eth0: adding default route via 10.77.10.1learner@tablet:~$ ip -4 address show eth08: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns sw-home
inet 10.77.10.105/24 brd 10.77.10.255 scope global dynamic noprefixroute eth0
valid_lft 43200sec preferred_lft 37800seclearner@tablet:~$ ip routedefault via 10.77.10.1 dev eth0 proto dhcp src 10.77.10.105 metric 1008
10.77.10.0/24 dev eth0 proto dhcp scope link src 10.77.10.105 metric 1008 learner@tablet:~$ Steps (12)
- Type
sudo dhcpcd -4 eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
dhcpcd-10.0.6 starting network namespace: tablet eth0: soliciting a DHCP lease eth0: offered 10.77.10.105 from 10.77.10.1 eth0: probing address 10.77.10.105/24 eth0: leased 10.77.10.105 for 43200 seconds eth0: adding route to 10.77.10.0/24 eth0: adding default route via 10.77.10.1 - Type
ip -4 address show eth0 - Press Enter
- Output:
8: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns sw-home inet 10.77.10.105/24 brd 10.77.10.255 scope global dynamic noprefixroute eth0 valid_lft 43200sec preferred_lft 37800sec - Type
ip route - Press Enter
- Output:
default via 10.77.10.1 dev eth0 proto dhcp src 10.77.10.105 metric 1008 10.77.10.0/24 dev eth0 proto dhcp scope link src 10.77.10.105 metric 1008
Stop terminal 1 with Ctrl+C when those four messages have arrived. In the verbose output, DHCP-Message (53) names the actual message. The word Request on a plain BOOTP/DHCP address line alone would not distinguish Discover from Request. Read the named type, then connect it to the address line directly above it.
The first address reading contains 10.77.10.105/24; the default route uses 10.77.10.1. The leased address and counters can change: your number will differ. Compare roles and message order rather than expecting identical times or identifiers.
Let the client choose an offer
Section titled “Let the client choose an offer”More than one DHCP server may answer a Discover. The client needs to choose an offer and tell servers which one it accepted. That is why this initial exchange includes a Request between the Offer and confirmation. The Request names the server it chose: find Server-ID (54), length 4: 10.77.10.1 beneath its message type in the listener. The server identifier carries that choice even though the Request itself is broadcast.
This exchange does not make tablet invent its own home address. The server proposes a value and the client asks to use it. Nor does router send a lease to every machine without being asked. Watch which direction starts the agreement.
Mistakes to recognize
Section titled “Mistakes to recognize”“The device chooses its own address.” In this join it requests the server’s offered lease.
“The server sends settings without being asked.” The first captured message comes from tablet, before either server reply.
Try it yourself
Section titled “Try it yourself”Keep a lease running on tablet and start the same filtered listener again in terminal 1. In terminal 2 run sudo ls -la /var/lib/dhcpcd/ before and after sudo dhcpcd -4 -k eth0. Then run sudo dhcpcd -4 eth0. Compare the new join with the stage. Find the Release and the four messages that follow it, then stop the listener with Ctrl+C. Finally release the client again after listening has stopped.
Solution
The -k option releases the lease and the lease file is gone, so the next start is a fresh four-message join. Keep -4 to address this IPv4 client’s control process. The listener’s DHCP-Message (53) lines distinguish the Release from the following Discover and Request, even though their plain address lines all say Request.
learner@tablet:~$ sudo dhcpcd -4 eth0[sudo] password for learner: dhcpcd-10.0.6 starting
network namespace: tablet
eth0: soliciting a DHCP lease
eth0: offered 10.77.10.105 from 10.77.10.1
eth0: probing address 10.77.10.105/24
eth0: leased 10.77.10.105 for 43200 seconds
eth0: adding route to 10.77.10.0/24
eth0: adding default route via 10.77.10.1learner@tablet:~$ sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:'tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 10.77.10.105.68 > 10.77.10.1.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 300, xid 0xadb65fa5, Flags [none]
DHCP-Message (53), length 1: Release
Server-ID (54), length 4: 10.77.10.1
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343, xid 0x1c45a7f2, Flags [none]
DHCP-Message (53), length 1: Discover
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x1c45a7f2, Flags [none]
DHCP-Message (53), length 1: Offer
Server-ID (54), length 4: 10.77.10.1
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352, xid 0x1c45a7f2, Flags [none]
DHCP-Message (53), length 1: Request
Server-ID (54), length 4: 10.77.10.1
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x1c45a7f2, Flags [none]
DHCP-Message (53), length 1: ACK
Server-ID (54), length 4: 10.77.10.1^C5 packets captured
5 packets received by filter
0 packets dropped by kernellearner@tablet:~$ sudo dhcpcd -4 -k eth0sending signal ALRM to pid 215
waiting for pid 215 to exitlearner@tablet:~$ Steps (16)
- Type
sudo dhcpcd -4 eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
dhcpcd-10.0.6 starting network namespace: tablet eth0: soliciting a DHCP lease eth0: offered 10.77.10.105 from 10.77.10.1 eth0: probing address 10.77.10.105/24 eth0: leased 10.77.10.105 for 43200 seconds eth0: adding route to 10.77.10.0/24 eth0: adding default route via 10.77.10.1 - Type
sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:' - Press Enter
- Output:
tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
10.77.10.105.68 > 10.77.10.1.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 300, xid 0xadb65fa5, Flags [none] DHCP-Message (53), length 1: Release Server-ID (54), length 4: 10.77.10.1 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 343, xid 0x1c45a7f2, Flags [none] DHCP-Message (53), length 1: Discover 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x1c45a7f2, Flags [none] DHCP-Message (53), length 1: Offer Server-ID (54), length 4: 10.77.10.1 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:77:10:00:01:00, length 352, xid 0x1c45a7f2, Flags [none] DHCP-Message (53), length 1: Request Server-ID (54), length 4: 10.77.10.1 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x1c45a7f2, Flags [none] DHCP-Message (53), length 1: ACK Server-ID (54), length 4: 10.77.10.1 - Press Ctrl + C
- Output:
5 packets captured 5 packets received by filter 0 packets dropped by kernel - Type
sudo dhcpcd -4 -k eth0 - Press Enter
- Output:
sending signal ALRM to pid 215 waiting for pid 215 to exit
learner@tablet:~$ sudo ls -la /var/lib/dhcpcd/[sudo] password for learner: total 16
drwxr-xr-x 1 root root 4096 Nov 29 12:21 .
drwxr-xr-x 1 root root 4096 Nov 29 07:49 ..
-rw-r----- 1 root root 302 Nov 29 12:21 eth0.leaselearner@tablet:~$ sudo dhcpcd -4 -k eth0sending signal ALRM to pid 178
waiting for pid 178 to exitlearner@tablet:~$ sudo ls -la /var/lib/dhcpcd/total 12
drwxr-xr-x 1 root root 4096 Nov 29 12:21 .
drwxr-xr-x 1 root root 4096 Nov 29 07:49 ..learner@tablet:~$ sudo dhcpcd -4 eth0dhcpcd-10.0.6 starting
network namespace: tablet
eth0: soliciting a DHCP lease
eth0: offered 10.77.10.105 from 10.77.10.1
eth0: probing address 10.77.10.105/24
eth0: leased 10.77.10.105 for 43200 seconds
eth0: adding route to 10.77.10.0/24
eth0: adding default route via 10.77.10.1learner@tablet:~$ ip -4 address show eth08: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns sw-home
inet 10.77.10.105/24 brd 10.77.10.255 scope global dynamic noprefixroute eth0
valid_lft 43200sec preferred_lft 37800seclearner@tablet:~$ Steps (18)
- Type
sudo ls -la /var/lib/dhcpcd/ - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
total 16 drwxr-xr-x 1 root root 4096 Nov 29 12:21 . drwxr-xr-x 1 root root 4096 Nov 29 07:49 .. -rw-r----- 1 root root 302 Nov 29 12:21 eth0.lease - Type
sudo dhcpcd -4 -k eth0 - Press Enter
- Output:
sending signal ALRM to pid 178 waiting for pid 178 to exit - Type
sudo ls -la /var/lib/dhcpcd/ - Press Enter
- Output:
total 12 drwxr-xr-x 1 root root 4096 Nov 29 12:21 . drwxr-xr-x 1 root root 4096 Nov 29 07:49 .. - Type
sudo dhcpcd -4 eth0 - Press Enter
- Output:
dhcpcd-10.0.6 starting network namespace: tablet eth0: soliciting a DHCP lease eth0: offered 10.77.10.105 from 10.77.10.1 eth0: probing address 10.77.10.105/24 eth0: leased 10.77.10.105 for 43200 seconds eth0: adding route to 10.77.10.0/24 eth0: adding default route via 10.77.10.1 - Type
ip -4 address show eth0 - Press Enter
- Output:
8: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns sw-home inet 10.77.10.105/24 brd 10.77.10.255 scope global dynamic noprefixroute eth0 valid_lft 43200sec preferred_lft 37800sec
- A client without an address can start with a local broadcast.
- Discover, Offer, Request, and Acknowledge form this fresh join.
- Release removes the remembered lease in the tested client.
Next, Leases, renewals, and options reads the lifetime and the settings inside a confirmation.
Further reading
Section titled “Further reading”- RFC 2131, section 3.1, for initial address allocation.
- Ubuntu dhcpcd manual, for IPv4 operation and release.