Practice: Getting Network Settings Automatically
On this page
A visitor’s device joins a network automatically. It receives an address but cannot reach the remote service. Save the configuration exchange before resetting anything. Your task is to connect the server’s answer to the client’s settings, identify the wrong option, and prove that the repair changed it.
Before you start
Section titled “Before you start”Finish When configuration fails. Stop existing listeners and release old clients. Leave machine shells and run netlab reset from the VM. Keep dhcp on and other modes off. Use only tablet for the client and listener. Keep your notes and capture file so you can explain the result after the experiment ends.
This practice deliberately supplies the wrong gateway. Knowing the fault’s name does not replace evidence: your diagnosis must still name the offered value, the applied route, and a failed next-hop observation.
Set goals before collecting rows
Section titled “Set goals before collecting rows”- Capture a fresh lease into your own saved file.
- Match the address, mask, gateway, name server, and lifetime to tablet’s configuration.
- Explain a local success alongside a remote failure.
- Correct the source of the wrong option and verify a fresh route.
Predict: If the server confirms a lease, does that guarantee the gateway in it is usable? Write your answer before starting. Keep it beside your table; you will return to it after the local and remote tests.
Mistakes to recognize
Section titled “Mistakes to recognize”Replacing the route by hand would hide the immediate symptom while leaving the wrong server option. Correct the cause before asking for configuration again.
Good to know
Section titled “Good to know”Keep separate filenames if you repeat the capture. Reusing lease.pcap overwrites the earlier evidence. A saved capture can be read after a lab reset; it records the earlier exchange, not the current settings.
Try it yourself
Section titled “Try it yourself”From the VM run netlab break dhcp-wrong-gateway. Open two tablet terminals with netlab shell tablet. In terminal 1 run sudo tcpdump -n -i eth0 -w lease.pcap port 67 or port 68. The -w option writes frames to the file instead of printing each frame. Give your Ubuntu password when asked.
In terminal 2 start sudo dhcpcd -4 eth0. Read ip -4 address show eth0, ip route, and cat /etc/resolv.conf. Test phone with ping -c 1 -W 1 10.77.10.11 and web with ping -c 1 -W 1 10.77.20.80. Read ip neigh show 10.77.10.254 after the remote attempt. The one-second timeout limits each reply wait.
Return to terminal 1 and press Ctrl+C. Run tcpdump -n -v -r lease.pcap 'udp src port 67'. The quotes keep this filter together. It selects the server’s replies from the saved file; it does not delete the other frames. Record the option-to-setting table before opening the solution.
Compare the default next hop with the intended router. Explain which command establishes that the next hop cannot be resolved. Then leave both tablet shells and run netlab fix from the VM. Open a fresh tablet shell, obtain configuration again, inspect the route, and repeat the remote test.
Expected evidence
Section titled “Expected evidence”Keep the saved file, the option table, the wrong route, and the neighbor reading. Add the corrected route and the successful remote test after repair. Write one sentence linking each failure to its setting. Include a note that the address and timings may vary; your number will differ.
Do not use ping timing as the deciding observation. You are investigating configuration, rather than measuring performance. Likewise, a count of four messages establishes a fresh exchange but says nothing about whether the gateway was configured correctly on the server.
Read the ACK, rather than treating an Offer alone as permission to use the address. The address is in the Your-IP field. The prefix comes from the mask. The gateway is a different option from the name server, even though both contain addresses.
Solution
learner@tablet:~$ sudo tcpdump -n -i eth0 -w lease.pcap port 67 or port 68[sudo] password for learner: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes^C4 packets captured
4 packets received by filter
0 packets dropped by kernellearner@tablet:~$ tcpdump -n -v -r lease.pcap 'udp src port 67'reading from file lease.pcap, link-type EN10MB (Ethernet), snapshot length 262144
12:38:23.952460 IP (tos 0xc0, ttl 64, id 48783, offset 0, flags [none], proto UDP (17), length 330)
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x500814d, Flags [none]
Your-IP 10.77.10.105
Server-IP 10.77.10.1
Client-Ethernet-Address 02:77:10:00:01:00
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message (53), length 1: Offer
Server-ID (54), length 4: 10.77.10.1
Lease-Time (51), length 4: 43200
RN (58), length 4: 21600
RB (59), length 4: 37800
Subnet-Mask (1), length 4: 255.255.255.0
BR (28), length 4: 10.77.10.255
Domain-Name (15), length 8: "lab.test"
Domain-Name-Server (6), length 4: 10.77.20.53
Default-Gateway (3), length 4: 10.77.10.254
12:38:23.959814 IP (tos 0xc0, ttl 64, id 48785, offset 0, flags [none], proto UDP (17), length 330)
10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x500814d, secs 3, Flags [none]
Your-IP 10.77.10.105
Server-IP 10.77.10.1
Client-Ethernet-Address 02:77:10:00:01:00
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message (53), length 1: ACK
Server-ID (54), length 4: 10.77.10.1
Lease-Time (51), length 4: 43200
RN (58), length 4: 21600
RB (59), length 4: 37800
Subnet-Mask (1), length 4: 255.255.255.0
BR (28), length 4: 10.77.10.255
Domain-Name (15), length 8: "lab.test"
Domain-Name-Server (6), length 4: 10.77.20.53
Default-Gateway (3), length 4: 10.77.10.254learner@tablet:~$ Steps (12)
- Type
sudo tcpdump -n -i eth0 -w lease.pcap port 67 or port 68 - 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 - Return from the client terminal, stop the capture, then read the saved replies.
- Press Ctrl + C
- Output:
4 packets captured 4 packets received by filter 0 packets dropped by kernel - Type
tcpdump -n -v -r lease.pcap 'udp src port 67' - Press Enter
- Output:
reading from file lease.pcap, link-type EN10MB (Ethernet), snapshot length 262144 12:38:23.952460 IP (tos 0xc0, ttl 64, id 48783, offset 0, flags [none], proto UDP (17), length 330) 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x500814d, Flags [none] Your-IP 10.77.10.105 Server-IP 10.77.10.1 Client-Ethernet-Address 02:77:10:00:01:00 Vendor-rfc1048 Extensions Magic Cookie 0x63825363 DHCP-Message (53), length 1: Offer Server-ID (54), length 4: 10.77.10.1 Lease-Time (51), length 4: 43200 RN (58), length 4: 21600 RB (59), length 4: 37800 Subnet-Mask (1), length 4: 255.255.255.0 BR (28), length 4: 10.77.10.255 Domain-Name (15), length 8: "lab.test" Domain-Name-Server (6), length 4: 10.77.20.53 Default-Gateway (3), length 4: 10.77.10.254 12:38:23.959814 IP (tos 0xc0, ttl 64, id 48785, offset 0, flags [none], proto UDP (17), length 330) 10.77.10.1.67 > 10.77.10.105.68: BOOTP/DHCP, Reply, length 302, xid 0x500814d, secs 3, Flags [none] Your-IP 10.77.10.105 Server-IP 10.77.10.1 Client-Ethernet-Address 02:77:10:00:01:00 Vendor-rfc1048 Extensions Magic Cookie 0x63825363 DHCP-Message (53), length 1: ACK Server-ID (54), length 4: 10.77.10.1 Lease-Time (51), length 4: 43200 RN (58), length 4: 21600 RB (59), length 4: 37800 Subnet-Mask (1), length 4: 255.255.255.0 BR (28), length 4: 10.77.10.255 Domain-Name (15), length 8: "lab.test" Domain-Name-Server (6), length 4: 10.77.20.53 Default-Gateway (3), length 4: 10.77.10.254
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.254learner@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.254 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:~$ cat /etc/resolv.conf# Written by dhcpcd on tablet (netlab) from the DHCP lease.
search lab.test
nameserver 10.77.20.53learner@tablet:~$ ping -c 1 -W 1 10.77.10.11PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data.
64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.582 ms
--- 10.77.10.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.582/0.582/0.582/0.000 mslearner@tablet:~$ ping -c 1 -W 1 10.77.20.80PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data.
--- 10.77.20.80 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0mslearner@tablet:~$ ip neigh show 10.77.10.25410.77.10.254 dev eth0 INCOMPLETE learner@tablet:~$ Steps (24)
- 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.254 - 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.254 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 - Type
cat /etc/resolv.conf - Press Enter
- Output:
# Written by dhcpcd on tablet (netlab) from the DHCP lease. search lab.test nameserver 10.77.20.53 - Type
ping -c 1 -W 1 10.77.10.11 - Press Enter
- Output:
PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data. 64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.582 ms --- 10.77.10.11 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.582/0.582/0.582/0.000 ms - Type
ping -c 1 -W 1 10.77.20.80 - Press Enter
- Output:
PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data. --- 10.77.20.80 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms - Type
ip neigh show 10.77.10.254 - Press Enter
- Output:
10.77.10.254 dev eth0 INCOMPLETE
| Captured item | Value | Compare with |
|---|---|---|
| Your-IP | 10.77.10.105 |
inet address |
| Subnet-Mask, option 1 | 255.255.255.0 |
/24 prefix |
| Default-Gateway, option 3 | 10.77.10.254 |
default via route |
| Domain-Name-Server, option 6 | 10.77.20.53 |
/etc/resolv.conf |
| Lease-Time, option 51 | 43200 seconds |
Address lifetime at receipt |
| RN, option 58 | 21600 seconds |
Renewal timer |
| RB, option 59 | 37800 seconds |
Rebinding timer |
The read-back works without sudo in this capture. Keep any error your own terminal prints rather than assuming every system uses the same file permissions.
Phone answers while web does not. The route names 10.77.10.254, and the neighbor reading cannot resolve that next hop. The ACK really supplied the wrong gateway; the client applied it. Check your answer: a confirmed lease can contain an unusable option.
learner@rootvolt:~$ netlab fix[sudo] password for learner: Fault dhcp-wrong-gateway removed.learner@rootvolt:~$ netlab shell tabletlearner@tablet:~$ ip -4 address show eth0learner@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: ignoring offer of 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 routedefault via 10.77.10.1 dev eth0 proto dhcp src 10.77.10.105 metric 1020
10.77.10.0/24 dev eth0 proto dhcp scope link src 10.77.10.105 metric 1020 learner@tablet:~$ ping -c 1 -W 1 10.77.20.80PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data.
64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.212 ms
--- 10.77.20.80 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.212/0.212/0.212/0.000 mslearner@tablet:~$ sudo dhcpcd -4 -k eth0sending signal ALRM to pid 347
waiting for pid 347 to exitlearner@tablet:~$ exitlogoutlearner@rootvolt:~$ Steps (28)
- Type
netlab fix - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Fault dhcp-wrong-gateway removed. - Type
netlab shell tablet - Press Enter
- Type
ip -4 address show eth0 - Press Enter
- 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: ignoring offer of 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 route - Press Enter
- Output:
default via 10.77.10.1 dev eth0 proto dhcp src 10.77.10.105 metric 1020 10.77.10.0/24 dev eth0 proto dhcp scope link src 10.77.10.105 metric 1020 - Type
ping -c 1 -W 1 10.77.20.80 - Press Enter
- Output:
PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data. 64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.212 ms --- 10.77.20.80 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.212/0.212/0.212/0.000 ms - Type
sudo dhcpcd -4 -k eth0 - Press Enter
- Output:
sending signal ALRM to pid 347 waiting for pid 347 to exit - Type
exit - Press Enter
- Output:
logout
The repair resets the lab machines, so the old client does not silently continue on the rebuilt tablet. Start dhcpcd again. The final release in the replay stops it after verification. Save both route readings so the change remains reviewable.
Recall check
Section titled “Recall check”Can a client have a valid address and still be unable to look up names?
Answer
Yes. Address assignment and name lookup are different services. A missing or unreachable name server can prevent lookup even when the interface has a valid address and local delivery works. Test names separately from numeric destinations.
- Preserve the exchange before changing state.
- Match an ACK’s options to the settings the client applied.
- Repair the source of an incorrect option and verify a fresh lease.
Next, How DNS Finds Services uses the name-server setting.
Further reading
Section titled “Further reading”- tcpdump manual, for writing, reading, and filtering a saved capture.