Skip to content

Investigating a lookup

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

Someone says “DNS is broken.” They might have received an unexpected address, asked for a missing name, waited for a reply that never came, or reached a port that refused a connection. Find out what happened before you change a setting.

Keep DNS mode on as in Names, zones, and records. Exit machine shells and run netlab reset from the VM if you have a fault active. Run lookups on laptop. Apply or clear a fault from the VM prompt.

Start with cat /etc/resolv.conf. Note the address on the nameserver line. Use it with @ to ask dns for the web address. Ask ns the same question. Both servers give the same data. If they ever differ, the resolver may still hold an old answer. Compare the seconds left, as in Caching and TTLs.

Next ask dns for AAAA. The previous command asked for IPv4 by default. This time the answer shows the IPv6 record. If a program needs one address type, test that type before changing the settings.

Read the settings, compare servers, and select a type
learner@laptop:~$ cat /etc/resolv.confnameserver 10.77.20.53
search lab.testlearner@laptop:~$ dig @10.77.20.53 web.lab.test +noall +answerweb.lab.test.		300	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.80learner@laptop:~$ dig @10.77.20.53 web.lab.test AAAA +noall +answerweb.lab.test.		300	IN	AAAA	fd85:b2a8:3761:20:77:20ff:fe00:80learner@laptop:~$ 

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. Read the configured server, ask both lab servers for the IPv4 address, then ask for the IPv6 address.
Steps (12)
  1. Type cat /etc/resolv.conf
  2. Press Enter
  3. Output: nameserver 10.77.20.53 search lab.test
  4. Type dig @10.77.20.53 web.lab.test +noall +answer
  5. Press Enter
  6. Output: web.lab.test. 300 IN A 10.77.20.80
  7. Type dig @10.77.20.54 web.lab.test +noall +answer
  8. Press Enter
  9. Output: web.lab.test. 300 IN A 10.77.20.80
  10. Type dig @10.77.20.53 web.lab.test AAAA +noall +answer
  11. Press Enter
  12. Output: web.lab.test. 300 IN AAAA fd85:b2a8:3761:20:77:20ff:fe00:80

On laptop, ask for nope.lab.test. Keep the status visible with +noall +comments +authority. The server sends back NXDOMAIN. On a timeout, dig reports that it received no DNS response.

The second command asks about the example domain from the Internet model so you can see how a refusal looks in the isolated lab. The lab server replies REFUSED. It declined the question, so the status gives no answer about whether the name exists.

Compare a missing name with a refused lookup
learner@laptop:~$ dig nope.lab.test +noall +comments +authority;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56533
;; 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. 1795960206 1200 180 1209600 300learner@laptop:~$ dig example.com +noall +comments +authority;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 63109
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; EDE: 14 (Not Ready)learner@laptop:~$ 

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 lab server responds in both cases, with NXDOMAIN for the missing lab name and REFUSED for the other question.
Steps (6)
  1. Type dig nope.lab.test +noall +comments +authority
  2. Press Enter
  3. Output: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56533 ;; 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. 1795960206 1200 180 1209600 300
  4. Type dig example.com +noall +comments +authority
  5. Press Enter
  6. Output: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 63109 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ; EDE: 14 (Not Ready)

Exit laptop and run netlab break wrong-dns from the VM. Enter laptop again and read the settings. The name-server address has changed to 10.77.20.99. Ask for the web name without specifying a server. The replay shows three timed-out attempts and then no servers could be reached. The wait in your run will vary.

While the fault is still on, ask 10.77.20.53 explicitly for the same name. The answer comes back. The two commands asked the same question at different addresses. Exit laptop and run netlab fix. Open a fresh shell on laptop and check the setting and lookup again.

Find and repair the wrong DNS setting
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 web.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 <<>> web.lab.test
;; global options: +cmd
;; no servers could be reachedlearner@laptop:~$ dig @10.77.20.53 web.lab.test +noall +answerweb.lab.test.		300	IN	A	10.77.20.80learner@laptop:~$ exitlogoutlearner@rootvolt:~$ netlab fixFault wrong-dns removed.learner@rootvolt:~$ netlab shell laptoplearner@laptop:~$ cat /etc/resolv.confnameserver 10.77.20.53
search lab.testlearner@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. The configured address times out. An explicit query works, and the repair restores the default lookup.
Steps (34)
  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 web.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 <<>> web.lab.test ;; global options: +cmd ;; no servers could be reached
  15. Type dig @10.77.20.53 web.lab.test +noall +answer
  16. Press Enter
  17. Output: web.lab.test. 300 IN A 10.77.20.80
  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 cat /etc/resolv.conf
  27. Press Enter
  28. Output: nameserver 10.77.20.53 search lab.test
  29. Type dig web.lab.test +noall +answer
  30. Press Enter
  31. Output: web.lab.test. 300 IN A 10.77.20.80
  32. Type exit
  33. Press Enter
  34. Output: logout

Test the connection after a correct answer

Section titled “Test the connection after a correct answer”

Predict. The lookup returns the right address but the page does not load. Is DNS the problem?

With the fault cleared, run curl -v http://web.lab.test:9999/ on laptop. The -v option shows connection details. Find the Trying line for 10.77.20.80:9999. The next line reports Connection refused. There is also a separate IPv6 attempt.

Resolve the name and try the closed port
learner@laptop:~$ curl -v http://web.lab.test:9999/* Host web.lab.test:9999 was resolved.
* IPv6: fd85:b2a8:3761:20:77:20ff:fe00:80
* IPv4: 10.77.20.80
*   Trying 10.77.20.80:9999...
* connect to 10.77.20.80 port 9999 from 10.77.10.10 port 39530 failed: Connection refused
*   Trying [fd85:b2a8:3761:20:77:20ff:fe00:80]:9999...
* Immediate connect fail for fd85:b2a8:3761:20:77:20ff:fe00:80: Network is unreachable
* Failed to connect to web.lab.test port 9999 after 1 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to web.lab.test port 9999 after 1 ms: Couldn't connect to serverlearner@laptop:~$ 

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. Curl tries the web address, then reports that the connection failed.
Steps (3)
  1. Type curl -v http://web.lab.test:9999/
  2. Press Enter
  3. Output: * Host web.lab.test:9999 was resolved. * IPv6: fd85:b2a8:3761:20:77:20ff:fe00:80 * IPv4: 10.77.20.80 * Trying 10.77.20.80:9999... * connect to 10.77.20.80 port 9999 from 10.77.10.10 port 39530 failed: Connection refused * Trying [fd85:b2a8:3761:20:77:20ff:fe00:80]:9999... * Immediate connect fail for fd85:b2a8:3761:20:77:20ff:fe00:80: Network is unreachable * Failed to connect to web.lab.test port 9999 after 1 ms: Couldn't connect to server * Closing connection curl: (7) Failed to connect to web.lab.test port 9999 after 1 ms: Couldn't connect to server
Check your answer

The address is correct. The connection to the chosen port fails after lookup. Opening and closing TCP connections shows what happens when a TCP port has no listener.

What you saw What it means Where to look next
Address returned Server answered the question Compare with the record on ns
NXDOMAIN Server says the name is missing Check the spelling and zone
Timeout No DNS reply reached dig Check the setting and test a known server
REFUSED Server declined the lookup Check whether it serves that question
Correct address, failed connection Lookup succeeded before the failure Check the port and service

When you see “refused,” check which program printed it. The dig output showed REFUSED as a DNS status. The curl output showed Connection refused after it had an address.

“If the name does not resolve, the server is down.” Under the fault, a lookup to the configured address times out and a direct lookup succeeds. In the missing-name case the DNS server even sends a status back.

“Using the address instead of the name is a fix.” It can bypass the lookup and hide the symptom. The direct query succeeds under the fault because addresses and the lab path still work. Programs that use the configured server still fail to resolve the name until you repair the setting.

Plain DNS gives the client no proof of who sent an answer. The listener in Resolvers and authoritative servers can read the names and answers. An observer on the path can read them too. If answers from different resolvers differ unexpectedly, check where they came from. First consider ordinary causes such as the stored answer from the previous lesson. Operating DHCP and DNS returns to this.

From laptop, choose a first lookup for each report. Run each test in the repaired lab. Write what the result tells you about the report.

  1. A tool reports that it could find no IPv4 address for phone.lab.test. Ask the configured lab server explicitly.
  2. An address lookup worked, but a mail tool reports no mail host for lab.test. Ask the server that holds the zone.
  3. Someone typed missing.lab.test and saw no address. Keep the reply status visible so you can distinguish a missing name from silence.
Solution

Ask dns for A in the first case. The address gives you a destination to test. Ask ns for MX in the second. That answer identifies the mail host. In the third case, NXDOMAIN is a reply about the missing name.

Check the address, the mail record, and the missing name
learner@laptop:~$ dig @10.77.20.53 phone.lab.test A +noall +answerphone.lab.test.		300	IN	A	10.77.10.11learner@laptop:~$ dig @10.77.20.54 lab.test MX +noall +answerlab.test.		300	IN	MX	10 web.lab.test.learner@laptop:~$ dig missing.lab.test A +noall +comments;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 45378
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232learner@laptop:~$ 

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. Ask the server and type that match each report, and read the status of the missing name.
Steps (9)
  1. Type dig @10.77.20.53 phone.lab.test A +noall +answer
  2. Press Enter
  3. Output: phone.lab.test. 300 IN A 10.77.10.11
  4. Type dig @10.77.20.54 lab.test MX +noall +answer
  5. Press Enter
  6. Output: lab.test. 300 IN MX 10 web.lab.test.
  7. Type dig missing.lab.test A +noall +comments
  8. Press Enter
  9. Output: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 45378 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232
  • Read the configured server before assuming where the lookup went.
  • Compare answers for the same name and type.
  • Separate a reply status, a timeout, and a later connection failure.

Next, Practice: How DNS Finds Services puts those distinctions to work.