online posts 16
wireshark 101

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.

you edit, in the labanswers/5.2.yml

open a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter

given
Capturemake 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 answersanswers/5.2.yml
new to this? step by stepbeginner
  1. make capture AT=laptop:eth1 NAME=5.2 X=search, open it, filter dns.
  2. Read the queries in order: which name came first? Filter dns.flags.response == 0 and count.
  3. Challenge: the response code for plain nas.
  4. Fill in answers/5.2.yml, then make check T=5.2.

more in meet the lab

1 explain

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.

2 show

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.

3 follow along

Count the queries

  1. Capture the laptop pinging a short name:

    run in the terminal
    make capture AT=laptop:eth1 NAME=5.2 X=search
    
  2. Open /captures/5.2.pcapng and filter only the questions:

    dns.flags.response == 0
    

    Read the first query’s name, then the Displayed count in the status bar.

  3. Fill in the follow-along lines:

    editanswers/5.2.ymlCtrl+P → 5.2.yml
    first_name: nas.lab
    queries: 6
    

    (Count yours: the checker counts the queries in your file.)

4 challenge

Why it gave up

  • bare_name_rcode: the response code the server gave for plain nas. 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.2

when 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