Use it to read the first lines of dig output: whether the lookup succeeded, who answered, and in what capacity.
DNS Header Field Reference
Every DNS message starts with a 12-byte header: an ID that ties answer to question, one-bit flags (authoritative, truncated, recursion desired/available, authentic data), a result code, and the counts of records in each section.
1. dig <name> <type> — read status:.
2. NOERROR → is ANSWER: above zero? Zero means no record of that type.
3. NXDOMAIN → the name is unknown in that server's view: typing error, missing record, or internal versus external DNS.
4. SERVFAIL → repeat with +cd; an answer then means DNSSEC validation is failing.
5. tc flag → the retry over TCP must be able to pass.
query sent with an ID → response with the same ID → status NOERROR → answer count above zero → flags show who answered (aa, or rd ra from a resolver)
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
dig www.example.com AVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational verification Verify boundary
dig www.example.com A
dig www.example.com A @192.0.2.53
dig www.example.com A +norecurse @ns1.example.com
The header is printed in the first lines of the output:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4711
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
status is the RCODE, flags lists the bits that are set, and the four counts follow. Naming a server with @ tests that server specifically. Asking a zone's own server with +norecurse shows the authoritative answer, with the aa flag.
In a capture, filter on dns and match query and response by ID.
Known-good: status NOERROR with an answer count above zero, and aa when the zone's own server is asked.
Step 2 Failure isolation workflow Narrow the fault
- NXDOMAIN. The name does not exist in the DNS that server sees: a typing error, a missing record, or a different view of the zone (internal versus external).
- NOERROR, ANSWER: 0. The name exists without that record type; check which type was asked for.
- SERVFAIL. The resolver could not complete the lookup: the zone's servers are unreachable or misdelegated, or DNSSEC validation failed. Asking again with
+cdseparates the two. - REFUSED. The server does not serve this client — an access list — or is not responsible for the name and does not recurse.
- No
raflag. The server is authoritative-only; it cannot be used as a resolver. tcis set. The answer was cut short; the retry over TCP must be able to get through.- No response at all. Not a DNS result: the server is unreachable or port 53 is filtered.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Three results are often confused: NOERROR with answers is success; NOERROR with zero answers means the name exists but has no record of that type; NXDOMAIN means the name does not exist at all. SERVFAIL means the resolver could not find out. aa marks an answer from the zone's own server.
dig <name> <type>— the header line:status,flags, and the four counts.dig <name> <type> @<server>— test one server.dig <name> <type> +norecurse @<authoritative server>— expect theaaflag.- Capture filter
dns— match query and response by ID.
ReferenceWhat it is1 section · depth on demand
Mechanics & mental model
Every DNS message, question or answer, starts with a 12-byte header. It carries a number that ties an answer to its question, a set of one-bit flags, a result code, and counts of the records in each of the four sections that follow.
ReferenceWhy it matters1 section · depth on demand
Why it matters operationally
The header is the summary of a DNS exchange. The result code says whether the lookup succeeded, and the flags say who answered and in what capacity — the zone's own server or a resolver passing on a cached answer. The header line that dig prints is this header, and reading it correctly distinguishes "the name does not exist" from "the name exists but has no such record" from "the server could not find out".
ReferenceHow it works1 section · depth on demand
How it works
| Field | Size | Meaning |
|---|---|---|
| ID | 16 bits | Chosen by the client; the answer carries the same value |
| QR | 1 bit | 0 = query, 1 = response |
| Opcode | 4 bits | 0 = standard query; 4 = notify, 5 = dynamic update |
| AA | 1 bit | Authoritative answer: the responding server holds the zone itself |
| TC | 1 bit | Truncated: the answer did not fit; ask again over TCP |
| RD | 1 bit | Recursion desired: the client asks the server to resolve the name fully |
| RA | 1 bit | Recursion available: the server is willing to do so |
| AD | 1 bit | Authentic data: the resolver validated the answer with DNSSEC |
| CD | 1 bit | Checking disabled: the client asks the resolver not to validate |
| RCODE | 4 bits | The result |
| QDCOUNT, ANCOUNT, NSCOUNT, ARCOUNT | 16 bits each | Number of entries in the question, answer, authority and additional sections |
Result codes.
| RCODE | Name | Meaning |
|---|---|---|
| 0 | NOERROR | The query was processed. Does not by itself mean an answer was found |
| 1 | FORMERR | The server could not interpret the query |
| 2 | SERVFAIL | The server failed to get an answer: upstream servers unreachable, or DNSSEC validation failed |
| 3 | NXDOMAIN | The name does not exist at all |
| 5 | REFUSED | The server will not answer this client or this question |
Three outcomes that are often confused.
- NOERROR with one or more answers — success.
- NOERROR with zero answers — the name exists, but has no record of the type asked for. Called NODATA; common when asking for AAAA of a name that only has an A record.
- NXDOMAIN — no record of any type exists under that name.
Reading the flags together. A response with aa came from a server responsible for the zone. A response with rd ra and no aa came from a recursive resolver, typically out of its cache. A response without ra to a query sent with rd means the server does not resolve for others; it will answer only for its own zones.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
The DNS header and what each bit tells you
Every DNS message starts with a 12-byte header, defined in RFC 1035:
- ID (16 bits): copied into the reply so it can be matched to the query.
- QR: 0 for a query, 1 for a response.
- Opcode (4 bits): 0 for a standard query.
- AA: the answer is authoritative.
- TC: the message was truncated.
- RD: recursion is desired, copied from the query.
- RA: recursion is available.
- Z: reserved.
- RCODE (4 bits): the response code.
Four 16-bit counts follow, for the question, answer, authority and additional sections.
Response codes (RFC 1035, with RFC 2308 names)
| RCODE | Name | Meaning |
|---|---|---|
| 0 | NOERROR | Success, though the answer may still be empty (NODATA) |
| 1 | FORMERR | The server couldn't interpret the query |
| 2 | SERVFAIL | The server failed (also DNSSEC validation failure) |
| 3 | NXDOMAIN | The name doesn't exist |
| 4 | NOTIMP | Query type not implemented |
| 5 | REFUSED | Policy refusal, such as recursion not allowed |
Flag combinations and their meaning
| Flags in the response | Interpretation |
|---|---|
qr aa | Answer from the authoritative server |
qr rd ra | Answer from a recursive resolver's cache or lookup |
qr rd without ra | The server won't recurse for you |
qr tc | Truncated: retry over TCP |
qr rd ra ad | DNSSEC-validated answer |
host$ dig @10.20.0.53 www.example.net A +noall +comments | grep -E "status|flags"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41187
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
host$ dig @ns1.example.net www.example.net A +norecurse +noall +comments | grep flags
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
host$ tshark -r dns.pcap -Y dns -T fields -e dns.id -e dns.flags.response -e dns.flags.rcode -e dns.qry.name | head
Matching queries to responses
The ID, together with the source port, links a reply to its query. Resolvers randomise both to make spoofed answers hard to inject. In a capture, use dns.id to pair queries and responses. A query without a matching response means loss or a silent drop.
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Network & Protocols → DNS Header Field Reference. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc1034.html · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Operational notes
Former standalone Cheat Sheet content now lives directly inside the Topic where it belongs.
DNS Header Flags
QR/AA/TC/RD/RA/AD/CD/RCODE.
30-second lookup
- Open Packet Field Explorer for field-level metadata.
- Use Packet Decoders for bit/flag values where relevant.
- Use Paste Output / Structured Parser for CLI evidence.
- Use Packet Filters to prove the wire boundary.
Evidence rule
A decoded field proves what is present in that packet/output at that moment. Continue through the verification chain before concluding end-to-end behavior.