Names and Answers
One query read properly, and the packet it travelled in.
Everyone edits DNS records. Almost nobody reads a DNS reply.
What DNS is for
Turning names into addresses, and a good deal more. Mail routing, certificate policy, domain ownership proofs and service discovery all live in the same database — chapter 3.
This course uses one tool. Every snippet is a dig against the live internet, so nothing
you run can change anything.
Your first dig
Four sections come back. Blank lines and the dig banner removed, the reply is this:
dig @1.1.1.1 example.com+short
When you want the answer and nothing else:
dig @1.1.1.1 +short example.com | sortThe header flags
One line carries the whole state of the reply:
dig @1.1.1.1 +noall +comments example.com | grep '^;; flags'| Flag | Means |
|---|---|
qr |
this is a response, not a question |
rd |
recursion was desired |
ra |
recursion is available here |
aa |
authoritative answer — this server owns the zone |
ad |
authenticated data — DNSSEC validated |
tc |
truncated, ask again over TCP |
aa is missing above because 1.1.1.1 does not own example.com. Ask a server that does:
dig @elliott.ns.cloudflare.com +noall +comments example.com | grep '^;; flags'aa appeared and ra vanished — an authoritative server owns the answer and will not
recurse for you. Chapter 4 is about that division.
Question and answer
The question is echoed back, so you can tell what was actually asked:
dig @1.1.1.1 +noall +question example.comThe answer is name, TTL, class, type, data — five columns:
dig @1.1.1.1 +noall +answer example.com | awk '{print $1,$4,$5}' | sortIN is the class, and in practice it is always IN — the others were defined in 1987 and
are museum pieces.
Who answered
Every reply names the server that produced it:
dig @1.1.1.1 example.com | grep '^;; SERVER'One question, one packet
A query is one UDP datagram to port 53, and the reply is one back. The original limit was 512 bytes, which is why so much of DNS is terse.
dig @1.1.1.1 example.com | grep 'MSG SIZE'Truncation and TCP
When an answer does not fit, the server sets tc and sends nothing useful:
dig @1.1.1.1 +ignore +bufsize=512 TXT google.com | grep '^;; flags'ANSWER: 0 — there is no data, only the instruction to ask again. A resolver retries over
TCP automatically; +ignore above told dig not to:
dig @1.1.1.1 +tcp +short example.com | sortEDNS0
An extension that raises the UDP limit, announced in a pseudo-section:
dig @1.1.1.1 example.com | grep '^; EDNS'1232 is the buffer this resolver will accept, chosen to stay under the real path MTU.
Without EDNS0 the ceiling is 512 bytes and almost every DNSSEC answer truncates.
The query ID
Sixteen bits, chosen by the client, echoed in the reply:
dig @1.1.1.1 example.com | grep 'HEADER'That number plus the source port is the only thing tying a reply to a question. A forged packet arriving first, with the right ID, is believed.