Skip to content

Practice: Getting Network Settings Automatically

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

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.

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

Replacing the route by hand would hide the immediate symptom while leaving the wrong server option. Correct the cause before asking for configuration again.

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.

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.

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
Save a lease and read its options
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:~$ 

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. Save the learner's lease capture, stop it, and read the server replies with verbose options.
Steps (12)
  1. Type sudo tcpdump -n -i eth0 -w lease.pcap port 67 or port 68
  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. Return from the client terminal, stop the capture, then read the saved replies.
  8. Press Ctrl + C
  9. Output: 4 packets captured 4 packets received by filter 0 packets dropped by kernel
  10. Type tcpdump -n -v -r lease.pcap 'udp src port 67'
  11. Press Enter
  12. 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
Read the settings beside the saved lease
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:~$ 

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 applied settings and compare local and remote delivery while the capture runs.
Steps (24)
  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.254
  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.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
  13. Type cat /etc/resolv.conf
  14. Press Enter
  15. Output: # Written by dhcpcd on tablet (netlab) from the DHCP lease. search lab.test nameserver 10.77.20.53
  16. Type ping -c 1 -W 1 10.77.10.11
  17. Press Enter
  18. 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
  19. Type ping -c 1 -W 1 10.77.20.80
  20. Press Enter
  21. 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
  22. Type ip neigh show 10.77.10.254
  23. Press Enter
  24. 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.

Remove dhcp-wrong-gateway and rejoin
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:~$ 

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. Fix the server's option, rejoin after the rebuild, and verify default via 10.77.10.1 with a reply from web.
Steps (28)
  1. Type netlab fix
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: Fault dhcp-wrong-gateway removed.
  7. Type netlab shell tablet
  8. Press Enter
  9. Type ip -4 address show eth0
  10. Press Enter
  11. Type sudo dhcpcd -4 eth0
  12. Press Enter
  13. Output: [sudo] password for learner:
  14. Type the password (the terminal shows nothing)
  15. Press Enter
  16. 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
  17. Type ip route
  18. Press Enter
  19. 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
  20. Type ping -c 1 -W 1 10.77.20.80
  21. Press Enter
  22. 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
  23. Type sudo dhcpcd -4 -k eth0
  24. Press Enter
  25. Output: sending signal ALRM to pid 347 waiting for pid 347 to exit
  26. Type exit
  27. Press Enter
  28. 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.

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.

  • tcpdump manual, for writing, reading, and filtering a saved capture.