Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

DNS Header Field Reference

Direct answer

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.

When to use this

Use it to read the first lines of dig output: whether the lookup succeeded, who answered, and in what capacity.

First 30 seconds

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.

Operational verification

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
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard
Key commanddig www.example.com A
Scope / prerequisiteUse it to read the first lines of dig output: whether the lookup succeeded, who answered, and in what capacity.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 +cd separates 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 ra flag. The server is authoritative-only; it cannot be used as a resolver.
  • tc is 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 references

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.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key checks
  • 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 the aa flag.
  • 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

FieldSizeMeaning
ID16 bitsChosen by the client; the answer carries the same value
QR1 bit0 = query, 1 = response
Opcode4 bits0 = standard query; 4 = notify, 5 = dynamic update
AA1 bitAuthoritative answer: the responding server holds the zone itself
TC1 bitTruncated: the answer did not fit; ask again over TCP
RD1 bitRecursion desired: the client asks the server to resolve the name fully
RA1 bitRecursion available: the server is willing to do so
AD1 bitAuthentic data: the resolver validated the answer with DNSSEC
CD1 bitChecking disabled: the client asks the resolver not to validate
RCODE4 bitsThe result
QDCOUNT, ANCOUNT, NSCOUNT, ARCOUNT16 bits eachNumber of entries in the question, answer, authority and additional sections

Result codes.

RCODENameMeaning
0NOERRORThe query was processed. Does not by itself mean an answer was found
1FORMERRThe server could not interpret the query
2SERVFAILThe server failed to get an answer: upstream servers unreachable, or DNSSEC validation failed
3NXDOMAINThe name does not exist at all
5REFUSEDThe 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)

RCODENameMeaning
0NOERRORSuccess, though the answer may still be empty (NODATA)
1FORMERRThe server couldn't interpret the query
2SERVFAILThe server failed (also DNSSEC validation failure)
3NXDOMAINThe name doesn't exist
4NOTIMPQuery type not implemented
5REFUSEDPolicy refusal, such as recursion not allowed

Flag combinations and their meaning

Flags in the responseInterpretation
qr aaAnswer from the authoritative server
qr rd raAnswer from a recursive resolver's cache or lookup
qr rd without raThe server won't recurse for you
qr tcTruncated: retry over TCP
qr rd ra adDNSSEC-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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 1034

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%
Terminology layer

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.

Aliases that resolve here
dns flagsdns headerdns qr aa tc rd ra ad cd
Embedded quick reference

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.

Confirmation

Confirm action

Continue?