DNS fundamentals: refresher
Asks which servers are in charge of a zone.
dig @1.1.1.1 isitdns.net NSGO NOERROR and the zone nameservers
NO GO SERVFAIL, which means the resolver could not finish the walk
What DNS is#
DNS maps a name (example.com) to one or more typed resource records (A, AAAA, MX, TXT, …) through a hierarchy of servers that each know one piece of the answer or know who does (RFC 1034 section 2.4). A client asks a recursive resolver, which walks root, TLD, and authoritative until it gets an answer, then caches and returns it. A server can be authoritative for the zones it hosts and recursive for everything else; the aa flag below is what tells you which one answered.
See anatomy-of-a-query for the walk hop by hop and record-types for the full record-type index.
The flags in the DNS header#
A DNS message header packs a row of single-bit flags that tell you, at a glance, what kind of message this is. The ones you'll see most in query logs:
| Flag | Set when | Means |
|---|---|---|
qr | Response (not query) | qr=false is a question frame, qr=true is an answer frame. |
aa | Authoritative | The responder owns this zone. Check this before trusting an answer is canonical. |
tc | Truncated | UDP answer did not fit in the packet. Client should retry over TCP. |
rd | Recursion desired | Client wants the resolver to do the walking. Set on virtually every stub-resolver query. |
ra | Recursion available | Server is willing to recurse. Authoritative-only nameservers, like the roots and most TLDs, leave it unset. |
ad | Authenticated data | Resolver's assertion that DNSSEC validation succeeded, not proof: see dnssec. |
cd | Checking disabled | Client is asking the resolver NOT to validate DNSSEC. Rare. |
Source: RFC 1035 section 4.1.1. An aa=1 answer with unexpected rdata is a zone misconfiguration, not the resolver's fault; missing RRSIGs under a published parent DS make a zone bogus and SERVFAIL for validating resolvers, while a zone with no DS at the parent is insecure and its unsigned answers resolve normally (RFC 4035 section 4.3).
rcode: the answer's verdict#
| rcode | Meaning | When you see it |
|---|---|---|
NOERROR | Success | Normal answer. |
NXDOMAIN | Name does not exist | A typo, a policy filter, or a real misconfiguration. |
SERVFAIL | Server failure | Upstream broken, DNSSEC validation failed, recursion timed out. |
REFUSED | Server won't answer | Client outside the ACL, or recursion off and the name is not in an owned zone. |
FORMERR | Malformed query | Client bug or an EDNS option the server does not understand. |
NOTIMP | Not implemented | Query type or opcode not supported: 1.1.1.1 answers ANY with NOTIMP plus EDE 21, an operator policy choice (Cloudflare: Deprecating the DNS ANY meta-query type); RFC 8482 instead defines a minimal or synthesized HINFO answer to decline ANY. |
Source: RFC 1035 section 4.1.1.
TTL#
A record's TTL is how long a resolver may cache the answer before re-asking authoritative (RFC 1035 section 3.2.1). Short TTLs (60-300s) propagate a fix fast but cost more queries to authoritative; long TTLs (3600s+) are cheap on authoritative but a mistake can stay cached for up to the whole TTL, and longer at a resolver that serves stale data (RFC 8767). Every record in an RRset must carry the same TTL (RFC 2181 section 5.2).
Encrypted transport (DoT, DoH, DoQ) and the DNSSEC chain of trust are each a full page on their own: see dot-doh and dnssec.
RFCs#
- RFC 1034: concepts and facilities
- RFC 1035: wire format, header flags, rcodes, TTL
- RFC 6891: EDNS(0), the OPT pseudosection in the capture above
- RFC 4035: DNSSEC protocol, the
ad/cdflags - RFC 9499: DNS terminology
See also#
- query-types: recursive, iterative, and authoritative queries
- dnssec-troubleshooting: diagnosing
SERVFAILand broken chains - nslookup and dig: the two tools you will actually use
- The dig-along: a hands-on walkthrough using dig against live records
- The OSI model: the layers under DNS, plus public vs private vs documentation IPs