Skip to content

Practice: How DNS Finds Services

Module
How DNS Finds Services
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.1, GNU Bash 5.2.21, tcpdump 4.99.4
On this page

You have three reports from the lab. One person got an old address. One got a reply that said the name was missing. One waited and gave up. Reproduce the three results and collect enough evidence to explain each one to the next person who uses the lab.

Keep DNS mode on. Start with a reset from the VM and open two terminals. In the first, enter dns. Keep the second at the VM prompt until your first lookup. You’ll return to that prompt to apply the faults. Keep both terminals open so the capture continues when you switch.

  1. Resolve a lab name and identify the type and data in the answer.
  2. Compare the stored answer from dns with the answer from ns after the record changes.
  3. Save a capture and identify the machines in the question and answer you read back.
  4. Classify the old answer, the missing name, and the silence, with evidence for each.
  5. Remove each fault and verify that a normal lookup works again.

For each lookup, write which machine asked, the server it used, and the question. Keep the returned record or exact status. If the terminal times out, keep an error line and the final message. For the comparison, keep both answers side by side and underline the data that differs. Keep the remaining seconds as evidence about the stored answer.

Use the saved capture to identify one question from laptop and its matching reply. Write where you ran the listener. A question that goes directly from laptop to ns takes a different path. The capture shows the messages visible on the interface of dns.

After each repair, compare the answer with the one you had before applying that fault. Keep that final check in your notes. It shows what changed when you repaired the lab.

An ordinary query uses the name-server setting. The @ form lets you hold the name and type fixed while changing the destination. Keep the comments visible when you need a status. Refresh the lab between faults because the tool applies one at a time.

If both servers show the changed address right away, check whether you asked dns before the change. That first lookup gives the resolver an answer to keep.

The listener’s -w option writes the capture to a file. After stopping it, -r reads the saved packets. The file is in your lab user’s home directory. Keep the interface and filter in your notes so you can explain what the file covers.

In the terminal on dns, run sudo tcpdump -n -i eth0 -w dns-practice.pcap port 53. Enter your password when asked. In the second terminal, enter laptop and resolve web.lab.test to fill the cache. Exit laptop. From the VM, run netlab break dns-change. Enter laptop again and ask each server explicitly for the same address record. Ask the configured server for nope.lab.test with the status visible. Exit laptop when the lookups finish.

Return to the listener and press Ctrl+C. Read the file with tcpdump -n -r dns-practice.pcap. Then exit the shell on dns and run netlab fix on the VM. Enter laptop and repeat the original lookup. Exit again before applying the second fault.

Apply netlab break wrong-dns on the VM. Enter laptop again and read the setting. Look up phone.lab.test using that setting and wait until the command finishes. Repeat with the known server explicitly selected. Exit the shell and run netlab fix. Enter laptop again and verify that the ordinary lookup works. Before opening the solution, label each result and tie it to a line you recorded.

Solution
Save and read the DNS traffic on dns
learner@rootvolt:~$ netlab shell dns[sudo] password for learner: learner@dns:~$ sudo tcpdump -n -i eth0 -w dns-practice.pcap port 53[sudo] password for learner: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes^C10 packets captured
10 packets received by filter
0 packets dropped by kernellearner@dns:~$ tcpdump -n -r dns-practice.pcapreading from file dns-practice.pcap, link-type EN10MB (Ethernet), snapshot length 262144
13:54:03.810362 IP 10.77.10.10.59436 > 10.77.20.53.53: 40144+ [1au] A? web.lab.test. (53)
13:54:03.810986 IP 10.77.20.53.54777 > 10.77.20.54.53: 18834+ [1au] A? web.lab.test. (53)
13:54:03.811240 IP 10.77.20.54.53 > 10.77.20.53.54777: 18834*- 1/1/1 A 10.77.20.80 (90)
13:54:03.811336 IP 10.77.20.53.53 > 10.77.10.10.59436: 40144* 1/1/1 A 10.77.20.80 (90)
13:54:08.596002 IP 10.77.10.10.58381 > 10.77.20.53.53: 51320+ [1au] A? web.lab.test. (53)
13:54:08.596100 IP 10.77.20.53.53 > 10.77.10.10.58381: 51320 1/0/1 A 10.77.20.80 (57)
13:54:09.633591 IP 10.77.10.10.58037 > 10.77.20.53.53: 55593+ [1au] A? nope.lab.test. (54)
13:54:09.633712 IP 10.77.20.53.60387 > 10.77.20.54.53: 1448+ [1au] A? nope.lab.test. (54)
13:54:09.633798 IP 10.77.20.54.53 > 10.77.20.53.60387: 1448 NXDomain*- 0/1/1 (119)
13:54:09.633870 IP 10.77.20.53.53 > 10.77.10.10.58037: 55593 NXDomain* 0/1/1 (119)learner@dns:~$ exitlogoutlearner@rootvolt:~$ netlab fixFault dns-change removed.learner@rootvolt:~$ netlab shell laptoplearner@laptop:~$ dig web.lab.test +noall +answerweb.lab.test.		300	IN	A	10.77.20.80learner@laptop:~$ exitlogoutlearner@rootvolt:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.1), GNU Bash 5.2.21. Save the listener traffic, read it back after stopping, and clear the record-change fault.
Steps (31)
  1. Type netlab shell dns
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Type sudo tcpdump -n -i eth0 -w dns-practice.pcap port 53
  7. Press Enter
  8. Output: [sudo] password for learner:
  9. Type the password (the terminal shows nothing)
  10. Press Enter
  11. Output: tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
  12. Carry out the lookups and change in the second terminal, then return and stop the listener.
  13. Press Ctrl + C
  14. Output: 10 packets captured 10 packets received by filter 0 packets dropped by kernel
  15. Type tcpdump -n -r dns-practice.pcap
  16. Press Enter
  17. Output: reading from file dns-practice.pcap, link-type EN10MB (Ethernet), snapshot length 262144 13:54:03.810362 IP 10.77.10.10.59436 > 10.77.20.53.53: 40144+ [1au] A? web.lab.test. (53) 13:54:03.810986 IP 10.77.20.53.54777 > 10.77.20.54.53: 18834+ [1au] A? web.lab.test. (53) 13:54:03.811240 IP 10.77.20.54.53 > 10.77.20.53.54777: 18834*- 1/1/1 A 10.77.20.80 (90) 13:54:03.811336 IP 10.77.20.53.53 > 10.77.10.10.59436: 40144* 1/1/1 A 10.77.20.80 (90) 13:54:08.596002 IP 10.77.10.10.58381 > 10.77.20.53.53: 51320+ [1au] A? web.lab.test. (53) 13:54:08.596100 IP 10.77.20.53.53 > 10.77.10.10.58381: 51320 1/0/1 A 10.77.20.80 (57) 13:54:09.633591 IP 10.77.10.10.58037 > 10.77.20.53.53: 55593+ [1au] A? nope.lab.test. (54) 13:54:09.633712 IP 10.77.20.53.60387 > 10.77.20.54.53: 1448+ [1au] A? nope.lab.test. (54) 13:54:09.633798 IP 10.77.20.54.53 > 10.77.20.53.60387: 1448 NXDomain*- 0/1/1 (119) 13:54:09.633870 IP 10.77.20.53.53 > 10.77.10.10.58037: 55593 NXDomain* 0/1/1 (119)
  18. Type exit
  19. Press Enter
  20. Output: logout
  21. Type netlab fix
  22. Press Enter
  23. Output: Fault dns-change removed.
  24. Type netlab shell laptop
  25. Press Enter
  26. Type dig web.lab.test +noall +answer
  27. Press Enter
  28. Output: web.lab.test. 300 IN A 10.77.20.80
  29. Type exit
  30. Press Enter
  31. Output: logout
Compare the old answer, the changed record, and a missing name
learner@rootvolt:~$ netlab shell laptop[sudo] password for learner: learner@laptop:~$ dig web.lab.test +noall +answerweb.lab.test.		300	IN	A	10.77.20.80learner@laptop:~$ exitlogoutlearner@rootvolt:~$ netlab break dns-changeFault dns-change applied.learner@rootvolt:~$ netlab shell laptoplearner@laptop:~$ dig @10.77.20.53 web.lab.test +noall +answerweb.lab.test.		295	IN	A	10.77.20.80learner@laptop:~$ dig @10.77.20.54 web.lab.test +noall +answerweb.lab.test.		300	IN	A	10.77.20.81learner@laptop:~$ dig nope.lab.test +noall +comments +authority;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55593
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; AUTHORITY SECTION:
lab.test.		300	IN	SOA	ns.lab.test. hostmaster.ns.lab.test. 1795960447 1200 180 1209600 300learner@laptop:~$ exitlogoutlearner@rootvolt:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.1), GNU Bash 5.2.21. Prime the stored answer, change the record, and compare the two servers before checking a missing name.
Steps (28)
  1. Type netlab shell laptop
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Type dig web.lab.test +noall +answer
  7. Press Enter
  8. Output: web.lab.test. 300 IN A 10.77.20.80
  9. Type exit
  10. Press Enter
  11. Output: logout
  12. Type netlab break dns-change
  13. Press Enter
  14. Output: Fault dns-change applied.
  15. Type netlab shell laptop
  16. Press Enter
  17. Type dig @10.77.20.53 web.lab.test +noall +answer
  18. Press Enter
  19. Output: web.lab.test. 295 IN A 10.77.20.80
  20. Type dig @10.77.20.54 web.lab.test +noall +answer
  21. Press Enter
  22. Output: web.lab.test. 300 IN A 10.77.20.81
  23. Type dig nope.lab.test +noall +comments +authority
  24. Press Enter
  25. Output: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55593 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; AUTHORITY SECTION: lab.test. 300 IN SOA ns.lab.test. hostmaster.ns.lab.test. 1795960447 1200 180 1209600 300
  26. Type exit
  27. Press Enter
  28. Output: logout

The resolver dns returns 10.77.20.80 with time left. The server ns returns 10.77.20.81 for the same name and type. Classify the first result as an old answer because the resolver still has the earlier record. The reply for nope.lab.test says NXDOMAIN. Classify it as a missing name because the server reports that the name is absent. After the repair, the usual server gives the original answer again.

Identify silence and verify the repair
learner@rootvolt:~$ netlab break wrong-dns[sudo] password for learner: Fault wrong-dns applied.learner@rootvolt:~$ netlab shell laptoplearner@laptop:~$ cat /etc/resolv.confnameserver 10.77.20.99
search lab.testlearner@laptop:~$ dig phone.lab.test;; communications error to 10.77.20.99#53: timed out
;; communications error to 10.77.20.99#53: timed out
;; communications error to 10.77.20.99#53: timed out

; <<>> DiG 9.18.39-0ubuntu0.24.04.9-Ubuntu <<>> phone.lab.test
;; global options: +cmd
;; no servers could be reachedlearner@laptop:~$ dig @10.77.20.53 phone.lab.test +noall +answerphone.lab.test.		300	IN	A	10.77.10.11learner@laptop:~$ exitlogoutlearner@rootvolt:~$ netlab fixFault wrong-dns removed.learner@rootvolt:~$ netlab shell laptoplearner@laptop:~$ dig phone.lab.test +noall +answerphone.lab.test.		300	IN	A	10.77.10.11learner@laptop:~$ exitlogoutlearner@rootvolt:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.1), GNU Bash 5.2.21. The configured server gives no response. An explicit query and then a repaired default query return the phone record.
Steps (31)
  1. Type netlab break wrong-dns
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: Fault wrong-dns applied.
  7. Type netlab shell laptop
  8. Press Enter
  9. Type cat /etc/resolv.conf
  10. Press Enter
  11. Output: nameserver 10.77.20.99 search lab.test
  12. Type dig phone.lab.test
  13. Press Enter
  14. Output: ;; communications error to 10.77.20.99#53: timed out ;; communications error to 10.77.20.99#53: timed out ;; communications error to 10.77.20.99#53: timed out ; <<>> DiG 9.18.39-0ubuntu0.24.04.9-Ubuntu <<>> phone.lab.test ;; global options: +cmd ;; no servers could be reached
  15. Type dig @10.77.20.53 phone.lab.test +noall +answer
  16. Press Enter
  17. Output: phone.lab.test. 300 IN A 10.77.10.11
  18. Type exit
  19. Press Enter
  20. Output: logout
  21. Type netlab fix
  22. Press Enter
  23. Output: Fault wrong-dns removed.
  24. Type netlab shell laptop
  25. Press Enter
  26. Type dig phone.lab.test +noall +answer
  27. Press Enter
  28. Output: phone.lab.test. 300 IN A 10.77.10.11
  29. Type exit
  30. Press Enter
  31. Output: logout

The default query times out under the second fault. Classify it as no response because no reply reached dig before it gave up. The working direct query and the changed setting show why this run failed. After the repair, the default query again returns the phone address.

Can a correct DNS answer still lead to a failed connection?

Answer

Yes. The address can be correct while the service is unable to accept a connection on the requested port.

  • Record the question and the server before comparing answers.
  • Use a saved capture to see who sent the visible messages.
  • Classify an old answer, a missing name, and silence separately.

Next: Everyday Application Traffic follows the messages that applications send after a name lookup. It is still in preparation.