Practice: How DNS Finds Services
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.
Before you start
Section titled “Before you start”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.
What you need to show
Section titled “What you need to show”- Resolve a lab name and identify the type and data in the answer.
- Compare the stored answer from
dnswith the answer fromnsafter the record changes. - Save a capture and identify the machines in the question and answer you read back.
- Classify the old answer, the missing name, and the silence, with evidence for each.
- Remove each fault and verify that a normal lookup works again.
Evidence to keep
Section titled “Evidence to keep”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.
Mistakes to recognize
Section titled “Mistakes to recognize”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.
Good to know
Section titled “Good to know”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.
Try it yourself
Section titled “Try it yourself”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
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:~$ Steps (31)
- Type
netlab shell dns - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
sudo tcpdump -n -i eth0 -w dns-practice.pcap port 53 - 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 - Carry out the lookups and change in the second terminal, then return and stop the listener.
- Press Ctrl + C
- Output:
10 packets captured 10 packets received by filter 0 packets dropped by kernel - Type
tcpdump -n -r dns-practice.pcap - Press Enter
- 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) - Type
exit - Press Enter
- Output:
logout - Type
netlab fix - Press Enter
- Output:
Fault dns-change removed. - Type
netlab shell laptop - Press Enter
- Type
dig web.lab.test +noall +answer - Press Enter
- Output:
web.lab.test. 300 IN A 10.77.20.80 - Type
exit - Press Enter
- Output:
logout
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:~$ Steps (28)
- Type
netlab shell laptop - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
dig web.lab.test +noall +answer - Press Enter
- Output:
web.lab.test. 300 IN A 10.77.20.80 - Type
exit - Press Enter
- Output:
logout - Type
netlab break dns-change - Press Enter
- Output:
Fault dns-change applied. - Type
netlab shell laptop - Press Enter
- Type
dig @10.77.20.53 web.lab.test +noall +answer - Press Enter
- Output:
web.lab.test. 295 IN A 10.77.20.80 - Type
dig @10.77.20.54 web.lab.test +noall +answer - Press Enter
- Output:
web.lab.test. 300 IN A 10.77.20.81 - Type
dig nope.lab.test +noall +comments +authority - Press Enter
- 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 - Type
exit - Press Enter
- 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.
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:~$ Steps (31)
- Type
netlab break wrong-dns - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Fault wrong-dns applied. - Type
netlab shell laptop - Press Enter
- Type
cat /etc/resolv.conf - Press Enter
- Output:
nameserver 10.77.20.99 search lab.test - Type
dig phone.lab.test - Press Enter
- 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 - Type
dig @10.77.20.53 phone.lab.test +noall +answer - Press Enter
- Output:
phone.lab.test. 300 IN A 10.77.10.11 - Type
exit - Press Enter
- Output:
logout - Type
netlab fix - Press Enter
- Output:
Fault wrong-dns removed. - Type
netlab shell laptop - Press Enter
- Type
dig phone.lab.test +noall +answer - Press Enter
- Output:
phone.lab.test. 300 IN A 10.77.10.11 - Type
exit - Press Enter
- 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.
Recall check
Section titled “Recall check”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.