DNS behaviour

This document defines the ordinary authoritative serving path implemented by internal/cache and internal/dnsserver. Static and generated record inputs are listed in the record reference. The reserved peer exchange is a separate authenticated protocol.

Authority, recursion and flags

Every cached positive local or imported answer is authoritative, including unzoned records, generated names and merged peer addresses. DNSZone, SOA and public parent delegation are optional for answering cached data. Referrals do not set AA. A known name with no requested RRset returns authoritative NOERROR/NODATA; a completely unknown name returns REFUSED with AA false, even beneath a configured SOA. The server does not generate NXDOMAIN.

There is no recursion, upstream forwarding, recursive cache or automatic public lookup in this path. RD never enables recursion; RA is always false. The HTTP diagnostic tool can explicitly query public resolvers, as described in DNS validation. That separate tool does not alter authoritative serving.

Only IN-class questions are served. The request must contain one question. Unsupported ordinary opcodes return NOTIMP, AXFR/IXFR return REFUSED, and invalid question structure returns FORMERR when a response can be constructed. The DNS library can ignore unparseable packets and packets marked as responses rather than answering them. No DNSSEC signing, validation or authenticated denial of existence is implemented.

Response decisions

Condition Result
Requested RRset exists in the selected authoritative zone NOERROR, AA, complete matching answer RRset subject to transport size handling.
Owner exists, but requested type is absent and no alias supplies an answer NOERROR/NODATA, AA true; optional applicable uncut-zone SOA in authority.
Owner and any applicable wildcard/DNAME source do not exist REFUSED, AA false.
Owner is an empty non-terminal established by data within an explicit zone NOERROR/NODATA, AA true; optional applicable uncut-zone SOA in authority.
Name is merely an inferred ancestor of an unzoned record REFUSED, AA false; no existence claim for public ancestors/root.
Bare DNSZone has SOA disabled, no NS and no records establishing its apex REFUSED; a zone object alone does not create a known apex.
Effective alias conflict, alias loop or excessive alias depth SERVFAIL from authoritative resolution.
Delegation applies with no independent positive or eligible known-name NODATA, request RD=false Referral NS in authority, eligible parent glue in additional, AA false.
Same unanswered delegation query with RD=true REFUSED, authority/glue cleared, AA and RA false.
No hosted zone matches Serve known unzoned data; a known owner with missing type gets authoritative NODATA without SOA, a completely unknown name gets REFUSED.
Unsupported EDNS version BADVERS with an EDNS version-zero OPT response.
Source query bucket exhausted REFUSED.
Concurrent query worker limit exhausted SERVFAIL.
Complete compressed response exceeds the TCP framing limit Small SERVFAIL, no answer/authority/additional data, AA and TC false.

Known-name NODATA deliberately establishes that this server has no requested type for that known owner. libc normally accepts it as a terminal answer instead of asking another configured nameserver for a missing A/AAAA family. This makes single-family names usable with musl AF_UNSPEC when another address family is absent, at the cost of missing-type fallback across servers with differing data. Nameserver lists should contain equivalent, converged mesh views rather than independent pieces of one owner's RRsets.

Completely unknown names remain REFUSED to permit fallback; they never become NXDOMAIN merely because a zone or SOA is configured. Data retained during a source outage remains known and answerable. Musl can query nameservers in parallel, so an unrelated public NXDOMAIN/NODATA can still win a race; observed TCP refusal/failure paths can also terminate without trying a healthy alternate. The actual glibc/musl results and limits are in resolver compatibility.

Zone selection and delegation

The longest matching hosted zone owns resolution; otherwise the unzoned bucket is consulted. Unzoned contributions are indexed under an applicable zone when one exists, without requiring one at definition time. A configured/imported child zone therefore takes precedence over its parent. Data contributed with parent zone ownership stays in the parent even when its textual owner lies beneath the child. Parent glue and parent wildcards cannot leak into the authoritative child answer or alter its CNAME masking/conflicts.

For the selected zone, an NS RRset below the apex creates a delegation unless that child is itself hosted. When no independent resolution applies, resolution stops at the first delegation cut when descending from the zone apex, even if another NS owner appears farther below it. The response places the cut's NS RRset in authority and returns A/AAAA glue for NS targets inside that delegated child's namespace, using the parent's zone-owned records. It does not fetch external glue.

For example, parent example.com. can hold a delegation for child.example.com. and glue for ns.child.example.com.. If child.example.com. is also hosted, queries use the child's records instead. Deleting the child's own address does not make the parent's glue an authoritative child address.

Matching and wildcards

Exact owners and their zone-scoped empty non-terminals are considered before wildcard synthesis. When no exact name exists, resolution finds the closest existing ancestor inside the selected zone and considers only *.<ancestor>. It does not continue searching for a broader wildcard if that closest-encloser wildcard is absent. Synthesized RRs use the original queried owner name.

An effective RR owner without the requested type suppresses wildcard fallback and produces NODATA. Empty non-terminals established inside an explicit zone also count as known names. A wildcard owner that exists only as an empty non-terminal inside that zone produces authoritative NOERROR/NODATA when it supplies no requested data. For example, _leaf.*.example.com. makes *.example.com. exist even without records directly at that owner. Parent-owned wildcards do not override a delegation or separately hosted child; standalone positive wildcard contributions have the independent-answer exception described below.

RRsets, ownership and ordering

Within an owning zone, contributions for the same name/type merge across local and peer sources. Canonically identical RDATA deduplicates, and the lowest TTL contributed to the RRset is applied to every returned member. Removing one source does not remove a matching member still owned by another source.

Ordinary multi-record answers whose first record is of the requested type rotate their answer order between lookups. The full RRset remains present when it fits the transport. CNAME chains retain their chain order. This is DNS round-robin; there is no endpoint health check or guarantee of equal application traffic.

ANY is deliberately limited rather than an enumeration of every type. It returns the first available RRset in this order: A, AAAA, CNAME, DNAME, NS, SOA, TXT, MX, SRV, CAA, PTR. If none exists at a known owner, it returns authoritative NODATA; a completely unknown owner remains REFUSED.

Address masking and CNAME chains

If any source supplies A or AAAA at an owner in the same zone, all CNAME data at that owner is masked from the serving view. The rule applies to the owner as a whole: an A-only contribution masks CNAME for AAAA and CNAME questions too. The underlying static/generated/imported source definition remains intact and is still eligible for local-only export. Removing the final address contributor allows the alias to become eligible again.

Without an address contribution, multiple distinct CNAME targets or a CNAME combined with other non-address records mark the authoritative owner as conflicting. Local configuration rejects applicable conflicts before saving; incompatible independent source contributions can meet at runtime and produce SERVFAIL. The cache does not select a target by arrival order.

A CNAME question returns the eligible alias itself. For other types, resolution adds the alias and follows its target only within available cached data, respecting explicit zone/delegation boundaries. Unknown targets or delegated targets without independent resolution return the alias without an upstream request. Eligible independent known-name NODATA at a target is followed just as an independently available positive is. The target may be in another locally hosted or imported zone. An unknown target returns the positive alias chain without attaching a refusal or negative SOA; no upstream request is made. Repeated names or a lookup depth above 16 produce SERVFAIL.

Apex metadata and negative caching

The selected zone generates an apex SOA only when enabled. DNSZone CRs default SOA false; legacy file zones with omitted soa preserve old enabled behaviour. Explicit configured NS entries generate apex NS independently; empty NS with SOA false produces no synthetic apex data. Static apex NS contributions also merge, with one minimum TTL across the NS RRset. Naming a nameserver does not generate its address records.

SOA field Implementation
MNAME First nameserver in the canonical sorted zone NS list.
RNAME Configured DNS-form administrator name.
Serial First 32 bits of the zone metadata/source-record SHA-256 digest, big-endian; zero becomes one.
Refresh 30 seconds.
Retry 10 seconds.
Expire 2,147,483,647 seconds.
SOA RR TTL and minimum/NODATA negative TTL Selected zone TTL.

The serial is reproducible for equivalent source state but is not monotonic. Peer synchronization does not order snapshots by SOA serials, and SOA expiry never removes retained authoritative data. Known-name NODATA includes a generated SOA only from an applicable uncut zone. An independently known owner below a parent delegation omits the parent SOA; the parent cannot assert missing-type authority for the delegated child. Without a zone or with SOA disabled, NODATA remains authoritative and has no synthetic SOA. Unknown-name REFUSED never includes an SOA or asserts NXDOMAIN. The architecture explains ownership and fingerprints.

UDP, TCP and EDNS

Both UDP and TCP are served on the DNS address. Responses use DNS name compression. UDP without EDNS is limited to 512 bytes. EDNS version zero sizes are clamped to the range 512–1232 bytes, regardless of a larger client offer. The response OPT uses version zero, does not echo DO, and does not implement additional options such as ECS, cookies or NSID.

When a UDP reply exceeds its permitted size, the server sets TC and removes any partially retained RRset in full. It may keep other complete RRsets that fit. Clients should retry over TCP to obtain the complete response.

TCP uses the normal two-byte DNS length prefix and supports repeated queries on one connection. A complete compressed response that still exceeds 65,535 bytes cannot fit that framing. The server returns a small SERVFAIL rather than closing silently or claiming a successful partial RRset. Per-record validation also requires wire encodability and a record length no greater than 60,000 bytes; many individually valid records can still make an oversized RRset.

The wire-serving path resolves immutable RRset descriptors and materializes records only within the compressed packet budget, including the original question and any response OPT. A huge cached RRset is not fully cloned or rotated just to produce a small truncated response. The same bound applies through CNAME/DNAME chains: aliases do not concatenate an oversized terminal RRset before checking size. Scratch packing buffers are pooled and bounded by the DNS message limit; retained candidate records are bounded by the selected transport budget. Administrative record views and source snapshots retain the complete dataset.

Admission and listener bounds

The ordinary per-source token bucket uses the observed remote IP after any Service/proxy address translation. Defaults are 100 queries/second and a burst of 200. Its 4,096-entry LRU evicts the least-recently used bucket when full; a returning evicted source starts a fresh bucket. Capacity does not turn every unseen source into a refused client.

Successfully verified TSIG requests using the current local key bypass this ordinary IP bucket. They still use the global query-worker limit, connection limit and the peer handler's authorization/transfer bounds. Unknown/retired keys cannot authorize transfers. Possession of the local key is sufficient; reciprocal outbound PeerSites are not required.

The application defaults to 256 simultaneous DNS workers and 256 accepted TCP connections. New TCP connections beyond the connection bound are closed; exhausted query workers receive SERVFAIL. Each TCP connection defaults to at most 1,024 queries. The internal MaxTCPQueries option is capped at 4,096 and is not an environment setting. Read/write deadlines are five seconds and the TCP idle timeout is ten seconds. These are per-operation/inactivity limits and a finite query count, not a separately configured absolute connection-age limit.

Startup waits for UDP and TCP activation; termination drains both within the application shutdown context. See capacity for sizing and representative load checks, and troubleshooting for refusal, SERVFAIL and reachability diagnosis.

DNAME subtree redirection

DNAME affects strict descendants, not the DNAME owner. A descendant query returns the applicable DNAME plus a synthesized CNAME replacing the suffix. Cached target records may follow that chain without recursion. An explicit descendant record does not override a DNAME redirection. Descendant NS records are occluded too: an owned DNAME encountered above a delegation takes precedence over that lower cut. A delegation above the owned DNAME and a separately hosted child zone keep their normal boundaries. Standalone DNAMEs retain their independent resolution behaviour described below.

A CNAME-type descendant query returns the DNAME/synthesized-CNAME pair. A DNAME query at the owner returns the DNAME itself. Long rewritten names return YXDOMAIN with the DNAME; loops/depth violations and incompatible targets return SERVFAIL. RRset rotation preserves the ordering of alias chains and rotates each contiguous RRset separately. Local configuration rejects multiple distinct DNAME targets or DNAME/delegation conflicts before publication. When independently valid sources merge a DNAME and non-apex NS RRset at the same owner, that owner and its applicable subtree return authoritative SERVFAIL rather than choosing between a referral and a redirect. Removing the conflicting source restores normal resolution. Apex NS and DNAME may coexist. These rules follow RFC 6672 sections 2.3–2.4.

Standalone positives and delegation

An effective RRset with any zone-empty source contribution is independently answerable below a parent NS cut. Cached direct positives, CNAME-followed targets, wildcard positives and an applicable standalone ancestor DNAME may therefore answer authoritatively without requiring the zone root or SOA. Provenance is tracked after CNAME masking: a masked standalone alias alone cannot turn explicit parent-owned glue into an authoritative positive.

Explicit zone-owned parent data retains referral/glue semantics; this exception does not promote parent-owned glue into child authority or merge across a separately hosted child's boundary. An independently known standalone owner may also return authoritative NODATA for an absent type below that cut. If neither an independently known owner nor an independently usable positive/alias applies, the normal delegation referral is returned.

Stub queries and iterative referrals

The cache retains delegation referrals for iterative DNS use. At the listener, an RD=true query that would receive non-authoritative NOERROR with no answers and NS referral authority is converted to REFUSED with authority/glue cleared. AA and RA remain false. This avoids handing libc a referral it cannot follow and that it might treat as terminating NODATA. No recursion is performed.

RD=false queries (for example dig +norecurse) retain the ordinary referral and parent-owned glue. Independently cached positive answers remain authoritative for either RD setting. Positive CNAME/DNAME alias-only replies also remain positive; resolving an external alias target still requires the client's recursive resolver. See resolver compatibility.

Exact known-name boundary

Known names are effective cached RR owners, including owners synthesized from an applicable wildcard RRset. Empty non-terminals inferred from real data within an explicit zone also count. An unzoned standalone record does not establish known-name existence for its inferred ancestors: host.app.example. does not make app.example., example. or the root known. Those ancestor queries remain REFUSED unless independent data or explicit-zone semantics establishes them.

A bare DNSZone with SOA=false, no NS and no RR data establishing its apex does not make that apex known. An enabled SOA, explicit NS or other actual data does. SOA inclusion in NODATA is optional; knowledge is not conditional on having SOA. An independently known standalone owner below a parent delegation can return NODATA for absent types, while an owner known only as parent-owned glue keeps referral behaviour. The actual selected ANY RRset still requires independent provenance to bypass that cut; unrelated standalone types cannot promote an owned glue RRset into an authoritative positive.

Below a parent cut, independent knowledge of another type permits NODATA only when the requested type itself is absent and that owner's existence is independently established. It does not make an existing requested parent-owned glue RRset authoritative. That glue still receives the normal referral (or RD=true REFUSED). For example, standalone TXT alongside parent-owned A glue can supply TXT and missing-AAAA NODATA, but does not promote that A glue or an ANY selection of it. Independent NODATA below the cut never attaches the parent's SOA.