DNS (Domain Name System) is the internet’s distributed directory service. Applications usually resolve names through local cache, static host maps, or recursive resolvers before opening transport connections.

DNS is hierarchical and distributed. Most queries are cache hits; misses can require referrals from root to TLD to authoritative servers.

sequenceDiagram
  participant Client
  participant Resolver as Recursive Resolver
  participant Root as Root Server
  participant TLD as .com TLD Server
  participant Auth as Authoritative Server

  Client->>Resolver: Query api.example.com
  Resolver->>Root: Where are .com zones?
  Root->>Resolver: TLD server address
  Resolver->>TLD: Where is example.com?
  TLD->>Resolver: Authoritative server address
  Resolver->>Auth: What is api.example.com?
  Auth->>Resolver: 203.0.113.42 (TTL 300)
  Resolver->>Client: 203.0.113.42

If a name is a CNAME, the resolver follows the chain and returns the terminal record set subject to TTL and loop limits. NXDOMAIN and NODATA can be negative-cached for SOA-derived intervals, so disappearance is not instant.

Resolution and Transport

Classic DNS commonly uses UDP for ordinary queries, while TCP is an equally valid transport that general-purpose implementations must support and is required for truncation recovery (TC=1) and zone transfers. Encrypted resolver protocols start on their own transports: DoT uses TLS and DoH maps DNS messages onto HTTPS.

TypeLookup directionPayloadExample
AName → addressIPv4api.example.com → 203.0.113.42
AAAAName → addressIPv6api.example.com → 2001:db8::1
CNAMEAlias → targetNamewww.example.com → example.com
MXMail domain → exchangerHostnames with preferenceexample.com → 10 mail.example.com
TXTName → text valuesOne or more stringsSPF, DKIM selectors, verification
NSZone → nameserverHostnameDelegates example.com
SOAZone metadataSerial, refresh, retry timersDrives negative TTL behavior
PTRReversed name → hostDomain name42.113.0.203.in-addr.arpa → api.example.com
SRVService locatorTarget, port, priority_sip._tcp.example.com → 10 5 5060 sip1.example.com

Cache Windows, Failover, and Traffic Steering

DNS operations are cache operations. An authoritative change is only the beginning: recursive resolvers, operating systems, browsers, and applications may continue using the previous answer until its TTL expires. A safe migration controls the cache window before changing the destination and keeps the old destination healthy while stale answers remain possible.

Suppose api.example.com has a TTL of 86,400 seconds and must move from 203.0.113.10 to 203.0.113.20:

  1. Lower the TTL to 300 seconds while the old address is still authoritative.
  2. Wait at least 86,400 seconds: one complete old-TTL window. A resolver that cached the old record immediately before the reduction can legally keep it for that long.
  3. Verify the reduced TTL through several recursive resolvers with dig @resolver api.example.com A.
  4. Change the address and keep both old and new endpoints able to serve traffic for the expected stale-answer window.
  5. Monitor traffic, errors, certificate coverage, and dependencies from both destinations.
  6. Raise the TTL only after rollback is no longer likely.

Negative answers have their own SOA-derived cache lifetime. Creating a previously missing name can remain invisible until cached NXDOMAIN or NODATA answers expire.

Traffic-steering mechanisms have different boundaries:

MechanismWhat changesBoundary to remember
Multiple A/AAAA recordsReturns several addressesClients choose and cache differently; this is not health-aware by itself
Weighted answerReturns destinations in configured proportionsResolver caching and client concentration make percentages approximate
Geographic or latency policyChooses an answer from resolver or client-network signalsResolver location may not equal user location; EDNS Client Subnet has privacy and cache costs
Health-aware failoverStops returning a failed endpointExisting caches still contain the failed answer until TTL expiry
AnycastBGP advertises one address from many sitesRouting selects the site; DNS still returns the same address

Short TTLs speed answer changes but increase authoritative and recursive query load. Long TTLs improve cache efficiency but extend rollback and failover windows. Pick the TTL from the recovery contract, not a universal number.

Diagnostic sequence

dig api.example.com A
dig @1.1.1.1 api.example.com A
dig +trace api.example.com
dig example.com SOA
dig +dnssec api.example.com A
dig -x 203.0.113.20

Compare the local answer with a known recursive resolver, then use +trace to inspect delegation and authoritative data. Check the returned TTL, CNAME chain, authoritative nameservers, and SOA serial before blaming application networking. A correct authoritative answer with a stale recursive answer is a cache-window problem; different authoritative answers usually indicate incomplete zone publication or split-horizon policy.

DNS Security and Encrypted Transport

DNS security has two different channels. DNSSEC authenticates signed record sets so a validating resolver can detect forged or modified DNS data. DNS-over-TLS (DoT) and DNS-over-HTTPS (DoH) encrypt the connection between a client and its recursive resolver. Neither control provides the other’s guarantee.

DNSSEC data authentication

An authoritative zone signs record sets with a zone-signing key. The resolver obtains the corresponding DNSKEY record and validates a chain of DS delegations from a configured trust anchor, normally the DNS root. A valid signature proves that the signed answer came from the key owner and was not changed; it does not hide the queried name or make the returned service trustworthy.

root trust anchor
  -> DS for .com
  -> DNSKEY for .com
  -> DS for example.com
  -> DNSKEY for example.com
  -> RRSIG over api.example.com A

An authenticated denial response uses NSEC or NSEC3 records to prove that a requested name or type does not exist. Operators must rotate keys without breaking the DS/DNSKEY chain, monitor signature expiry, and verify positive and negative answers before a registrar or DNS-provider migration.

Encrypted resolver transport

DoT carries DNS messages over TLS, conventionally on port 853. DoH carries DNS requests over HTTPS and can share port 443 with other web traffic. Both authenticate the configured resolver’s TLS endpoint and protect the client-resolver hop from passive observation and on-path modification.

After that hop, the resolver still performs recursion and contacts authoritative infrastructure. DoT or DoH does not authenticate those answers, constrain what the resolver returns, or hide queries from the resolver. DNSSEC validation at the resolver or validating client authenticates signed data across those hops.

Threat-to-control map

ThreatPrimary controlResidual boundary
Blind forged UDP responseQuery-ID/source-port entropy; DNSSEC validationUnsigned zones cannot provide DNSSEC authenticity
On-path observation between client and resolverDoT or DoHThe recursive resolver still sees the query
Malicious or compromised resolver returning a signed-zone forgeryDNSSEC validationThe resolver can still block, delay, or alter unsigned data
Stale but correctly signed answerTTL and signature validityDNSSEC authenticates data; it does not guarantee freshness beyond protocol validity
Domain points to a malicious serviceTLS/application authentication and authorizationDNSSEC authenticates the DNS owner, not the service’s business behavior

Pitfalls

  • Long TTLs preserve stale answers longer than expected.
  • CNAME at zone apex cannot coexist with other zone-root records.
  • DNSSEC is not payload confidentiality.
  • Encrypted resolver transport moves trust to the configured recursive resolver; it does not make that resolver invisible or infallible.

Operations Questions

References