Investigating a lookup
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.
Before you start
Section titled “Before you start”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.
Read the setting, then choose a server
Section titled “Read the setting, then choose a server”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.
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:~$ Steps (12)
- Type
cat /etc/resolv.conf - Press Enter
- Output:
nameserver 10.77.20.53 search lab.test - Type
dig @10.77.20.53 web.lab.test +noall +answer - Press Enter
- Output:
web.lab.test. 300 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.80 - Type
dig @10.77.20.53 web.lab.test AAAA +noall +answer - Press Enter
- Output:
web.lab.test. 300 IN AAAA fd85:b2a8:3761:20:77:20ff:fe00:80
Read the reply status
Section titled “Read the reply status”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.
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:~$ Steps (6)
- Type
dig nope.lab.test +noall +comments +authority - Press Enter
- 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 - Type
dig example.com +noall +comments +authority - Press Enter
- 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)
Watch a lookup time out
Section titled “Watch a lookup time out”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.
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:~$ Steps (34)
- 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 web.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 <<>> web.lab.test ;; global options: +cmd ;; no servers could be reached - Type
dig @10.77.20.53 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 fix - Press Enter
- Output:
Fault wrong-dns removed. - Type
netlab shell laptop - Press Enter
- Type
cat /etc/resolv.conf - Press Enter
- Output:
nameserver 10.77.20.53 search lab.test - 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
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.
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:~$ Steps (3)
- Type
curl -v http://web.lab.test:9999/ - Press Enter
- 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.
Mistakes to recognize
Section titled “Mistakes to recognize”“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.
Good to know
Section titled “Good to know”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.
Try it yourself
Section titled “Try it yourself”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.
- A tool reports that it could find no IPv4 address for
phone.lab.test. Ask the configured lab server explicitly. - An address lookup worked, but a mail tool reports no mail host for
lab.test. Ask the server that holds the zone. - Someone typed
missing.lab.testand 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.
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:~$ Steps (9)
- Type
dig @10.77.20.53 phone.lab.test A +noall +answer - Press Enter
- Output:
phone.lab.test. 300 IN A 10.77.10.11 - Type
dig @10.77.20.54 lab.test MX +noall +answer - Press Enter
- Output:
lab.test. 300 IN MX 10 web.lab.test. - Type
dig missing.lab.test A +noall +comments - Press Enter
- 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.