Skip to content

The initial lease exchange

Module
Getting Network Settings Automatically
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, dhcpcd 10.0.6, tcpdump 4.99.4
Prerequisites
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.

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.

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

  1. tablet
  2. router
  3. phone
  1. Discover: tablet to router and phone
  2. Offer: router to tablet
  3. Request: tablet to router and phone
  4. Acknowledge: router to tablet

In the capture4 messages at tablet:eth0

  1. 1. Discover12: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. 2. Offer12: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. 3. Request12: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. 4. Acknowledge12: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

Step-by-step model built from captured frames · Frames captured at tablet:eth0 while running 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)
  1. 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
  2. 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
  3. 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
  4. 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.

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
Listen while tablet joins
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. The listener shows each address line, its DHCP message type, and the server identifier for one fresh join.
Steps (10)
  1. Type sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:'
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
  7. The second terminal finished. Return here and press Ctrl+C to stop listening.
  8. 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
  9. Press Ctrl + C
  10. Output: 4 packets captured 4 packets received by filter 0 packets dropped by kernel
Obtain one fresh lease and read the settings
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Start the client once and read the assigned address, prefix, and routes.
Steps (12)
  1. Type sudo dhcpcd -4 eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type ip -4 address show eth0
  8. Press Enter
  9. 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
  10. Type ip route
  11. Press Enter
  12. 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.

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.

“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.

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.

Listen to release and a fresh join
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Prepare a lease if needed, then listen to its Release and the four messages of the next join; stop listening before final cleanup.
Steps (16)
  1. Type sudo dhcpcd -4 eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type sudo tcpdump -l -n -v -i eth0 port 67 or port 68 | grep -E ' > |DHCP-Message|Server-ID \(54\), length 4:'
  8. Press Enter
  9. Output: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
  10. The second terminal finished. Return here and press Ctrl+C to stop listening.
  11. 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
  12. Press Ctrl + C
  13. Output: 5 packets captured 5 packets received by filter 0 packets dropped by kernel
  14. Type sudo dhcpcd -4 -k eth0
  15. Press Enter
  16. Output: sending signal ALRM to pid 215 waiting for pid 215 to exit
Release the lease, check the file, and join again
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Read the lease file before and after release, start again, and inspect the address.
Steps (18)
  1. Type sudo ls -la /var/lib/dhcpcd/
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type sudo dhcpcd -4 -k eth0
  8. Press Enter
  9. Output: sending signal ALRM to pid 178 waiting for pid 178 to exit
  10. Type sudo ls -la /var/lib/dhcpcd/
  11. Press Enter
  12. 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 ..
  13. Type sudo dhcpcd -4 eth0
  14. Press Enter
  15. 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
  16. Type ip -4 address show eth0
  17. Press Enter
  18. 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.