task 5.2 · chapter 5 of 8: dns · 15 min
The search domain
objective
Type one short name and count the lookups it really causes: the search domain, A and AAAA side by side, a server that refuses, and a retry.
answers/5.2.ymlopen a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter
| Capture | make capture AT=laptop:eth1 NAME=5.2 X=search: the laptop runs ping nas |
|---|---|
| The laptop's resolver settings | /etc/resolv.conf: search lab, from DHCP option 15 |
| Your answers | answers/5.2.yml |
new to this? step by stepbeginner
make capture AT=laptop:eth1 NAME=5.2 X=search, open it, filterdns.- Read the queries in order: which name came first? Filter
dns.flags.response == 0and count. - Challenge: the response code for plain
nas. - Fill in answers/5.2.yml, then
make check T=5.2.
more in meet the lab
What the resolver adds
You type a name; the computer asks for others
In task 5.1, dig asked for exactly the name you gave it. Most programs don’t use dig. They ask the
computer’s resolver, the part of the operating system that does lookups, and the resolver has opinions.
The laptop’s resolver reads /etc/resolv.conf:
search lab
nameserver 192.168.2.53
nameserver is the DNS server to ask, from DHCP option 6. search lab is the search domain, from DHCP
option 15: when you type a short name, try it with .lab on the end. So ping nas asks for nas.lab. That’s
handy at home and at work (type printer, get printer.lab), and it’s also why one typo can cause several
lookups.
A and AAAA, together
The resolver doesn’t know whether you want IPv4 or IPv6, so it asks for both at once: an A query and an AAAA query for every name it tries. That’s two queries before anything else happens, even here, where the hosts have IPv6 switched off.
Refused
A DNS server can also refuse to answer. REFUSED (rcode 5) means I won’t look that up for you: here, the
lab’s server only answers for names under lab, and nas on its own isn’t one. It’s a different answer from
NXDOMAIN (that name doesn’t exist), and in a capture the difference tells you where to look next: NXDOMAIN is
about the name, REFUSED is about the server.
in one sentence A short name goes through the search list first; each try is an A and an AAAA query; and every answer has a code that says why.
One ping, many queries
laptop:~# ping -c 1 -W 1 nas
ping: nas: Try again
That’s all ping says. The capture says a lot more:
4 1.446020376 192.168.1.175 → 192.168.2.53 DNS 67 Standard query 0xf1f9 A nas.lab
5 1.446262459 192.168.1.175 → 192.168.2.53 DNS 67 Standard query 0xf24d AAAA nas.lab
6 1.447611459 192.168.2.53 → 192.168.1.175 DNS 67 Standard query response 0xf1f9 No such name A nas.lab
7 1.447791543 192.168.2.53 → 192.168.1.175 DNS 67 Standard query response 0xf24d No such name AAAA nas.lab
8 1.447853501 192.168.1.175 → 192.168.2.53 DNS 63 Standard query 0xc69f A nas
9 1.447934876 192.168.1.175 → 192.168.2.53 DNS 63 Standard query 0xc7c9 AAAA nas
10 1.447985418 192.168.2.53 → 192.168.1.175 DNS 63 Standard query response 0xc69f Refused A nas
11 1.448006501 192.168.2.53 → 192.168.1.175 DNS 63 Standard query response 0xc7c9 Refused AAAA nas
13 3.955044002 192.168.1.175 → 192.168.2.53 DNS 63 Standard query 0xc69f A nas
...
Try again is the resolver’s way of reporting the REFUSED: it isn’t sure the name doesn’t exist, only that it got no answer.
Count the queries
Capture the laptop pinging a short name:
run in the terminalmake capture AT=laptop:eth1 NAME=5.2 X=searchOpen
/captures/5.2.pcapngand filter only the questions:dns.flags.response == 0Read the first query’s name, then the Displayed count in the status bar.
Fill in the follow-along lines:
editanswers/5.2.ymlCtrl+P → 5.2.ymlfirst_name: nas.lab queries: 6(Count yours: the checker counts the queries in your file.)
Why it gave up
bare_name_rcode: the response code the server gave for plainnas. A name (NXDOMAIN,REFUSED, …) or the number is fine.
Then look at the timing: after the server refused the plain name, what did the laptop do, and how long did it wait first?
hint
Filter dns.qry.name == "nas" && dns.flags.response == 1, and open the Flags line.
show the solutionanswers/5.2.yml
or pull it into your lab: make solve T=5.2, then git diff --staged shows what changed
bare_name_rcode: REFUSED
The lab’s DNS server only answers for names under lab (it’s set up with no upstream server to ask), so it
refused plain nas. The laptop’s resolver asked the same two questions again, with the same transaction IDs,
two and a half seconds later, got refused again, and gave up: Try again.
One short name, six queries and two and a half seconds. When an application takes a few seconds to say a host can’t be found, this is usually what’s going on.
5 check: run it, then prove it
$ make check T=5.2when it's right, you'll see
╭─ task 5.2 · the search domain
│ ✓ captures/5.2.pcapng: taken on laptop:eth1, 19 frames
│ ✓ the first name the laptop asked for (follow along): nas.lab
│ ✓ how many queries the one ping caused (follow along): ...
│ ✓ the response code the server gave for plain nas (challenge): ...
╰─ 4/4 checks passed verified