Web and networkingDive 01 of 12
DNS, before there is an address
Your laptop knows a name. The network needs an address. Follow a café Wi-Fi lookup through delegation, caches, signed answers and encrypted transports, down to every byte on the link.
- Levels
- 10
- Reading
- 43 min
- Depth
- Idea to Machine
- Published
You type www.example.com
The address is at the end of a trail of referrals.
Your laptop asks one resolver. On a cold cache, that resolver has several other people to ask.
- Root · .Delegation to .com + glue18 ms
- .com registryDelegation to example.com + glue22 ms
- example.com authorityCNAME edge.cdn.example.com.23 ms
- example.com authority192.0.2.80 · TTL 6025 ms
Same question, a second time
96ms cold8ms warmThe warm resolver answers from cache. The café round trip remains.
Run this lookup yourselfIllustrative fixed universe: the CDN name stays inside example.com’s zone. Timings come from the simulator: 8 ms to the resolver + 18 + 22 + 23 + 25 ms upstream. Bars share a 0–96 ms scale.
A name is a path through authority
You open a laptop on café Wi-Fi and type https://www.example.com/. The browser has a name, but an IP packet needs a destination address. Somewhere, a service must turn that name into an address before the browser can start its connection. That service is the Domain Name System: DNS.
A single global address book would be easy to describe and impossible to operate well. Every new domain, every migration and every failed server would require an update to the same service. DNS instead distributes responsibility. A domain owner controls a small part of a shared namespace, can delegate part of it to somebody else, and publishes answers through authoritative servers. Resolvers find those servers by following the delegation tree.
Read www.example.com. from right to left. The final dot is the root, a real zero-length label that people usually omit when typing. Below the root is com., then example.com., then www.example.com.. The dots separate labels; they do not necessarily mark separately administered zones. A A contiguous part of the DNS namespace served under one administrative authority, cut off from its parent by a delegation. may contain many names and many levels of labels.
For our café lookup, use a small fixed universe: www.example.com. is an alias for edge.cdn.example.com., and that CDN endpoint has address 192.0.2.80. Both names live in one zone. These are documentation names and addresses; the live example.com service has its own configuration. Keeping the endpoint inside this zone lets us see the alias lookup separately from another round of delegation discovery.
Authority flows down; referrals point to the next zone
Four jobs that often get called “the DNS server”
The stub resolver is the client-side machinery that asks for an answer. It usually knows a configured recursive resolver and delegates the search to it. The recursive resolver does that search, keeps a cache, retries failed upstreams and may validate DNSSEC signatures. Your router may forward its questions to another resolver instead of doing the whole walk itself.
An authoritative server serves data for zones it is responsible for. It can give the requested records, prove their absence, or refer the resolver to a delegated child. A registry manages registrations under a top-level domain and the corresponding delegation data. The registrar that sold a domain and the company hosting its authoritative DNS can be different organisations.
The root service is also distributed. There are 13 named root-server identities, A through M, served by many instances rather than 13 individual computers. Root operators publish a common root zone. The IANA root-server list identifies those operators; the .com delegation entry identifies Verisign as its sponsoring organisation. None of these operators needs a database of every web server address.
The first lookup pays for discovery
With an empty recursive cache, our model needs one café round trip plus four upstream round trips: root referral, .com referral, alias answer and target address. Those illustrative costs total 96 ms. They are a latency budget, not a prediction for your network. An existing recursive resolver is rarely completely empty: other users may already have warmed the root, .com and popular-domain entries.
The second lookup can cost just the café round trip, 8 ms in this model. A browser or OS cache could remove even that exchange. DNS therefore has two very different performance regimes: learning enough authority to answer a question, and reusing answers that remain fresh. The gap explains why a single lookup benchmark can be misleading.
DNS distributes authority over names. A resolver follows that authority, then reuses what it learns for a bounded time.
The first resolver is on your laptop
The browser does not begin by broadcasting to root servers. First it decides whether it needs a lookup at all. A reusable connection may already exist. Its host cache may already hold addresses. If it needs resolution, it can ask the operating system or use browser-owned resolver machinery, depending on configuration and platform.
A native Unix program commonly calls getaddrinfo(). That API returns address candidates; it does not promise that a DNS packet will be sent. On systems using glibc’s Name Service Switch, the hosts: line in /etc/nsswitch.conf controls the sources and their ordering. The files source reads /etc/hosts. Other sources may consult a local resolver service, traditional DNS, multicast DNS or organisation-specific naming systems.
For example, hosts: files dns means “try local host mappings, then DNS,” subject to the service’s status rules. A real machine can have a more complicated line with bracketed actions. An entry mapping www.example.com in the hosts file can settle the request before any external DNS lookup. Search domains can turn short names into several questions; a fully qualified name with a final dot removes that particular ambiguity.
OS caching depends on the stack. Linux installations may use systemd-resolved, sometimes reached through a local stub listener at 127.0.0.53; other installations use a different service or no system-wide cache. Apple platforms commonly use mDNSResponder for unicast DNS as well as multicast naming. The executable’s name does not mean every request is sent with mDNS. In particular, .local names have special multicast semantics, unlike our globally delegated .com name.
Two possible routes from one application
Chrome can own the DNS client
Chromium’s network stack includes a built-in asynchronous DNS client and host caches. Its resolver can use system resolution, built-in DNS tasks or secure DNS tasks according to settings, platform support and failure policy. That is more precise than saying “Chrome always bypasses the OS”: it also reads host mappings and tracks system network configuration. The Chrome Host Resolution documentation describes these paths and the conditions that select them.
Where does the recursive server address come from? Often the Wi-Fi network supplies it through DHCP or IPv6 configuration. The address may belong to the router, which forwards requests elsewhere. A manually configured or browser-selected encrypted resolver can change the path. The browser must also bootstrap an encrypted resolver’s hostname somehow, using configured addresses, cached data or another resolution path.
Two address families, one impatient application
A web connection may need both A records for IPv4 and AAAA records for IPv6. Happy Eyeballs v2, RFC 8305 §3, recommends sending the AAAA question first and the A question immediately afterwards. Resolution is asynchronous: do not wait indefinitely for the slower family before using the one that arrived.
If A arrives first, the recommended resolution delay gives AAAA up to 50 ms to catch up. The later connection-attempt delay, commonly 250 ms without better RTT information, is a different timer. Happy Eyeballs races connection opportunities, not merely two DNS packets. A fast A answer can still lead to a slower connection than a slightly later AAAA answer, and an unreachable IPv6 route should not hold the user hostage.
Our simulator follows A only so its cache and referral sequence remain legible. The corresponding AAAA request can share delegation knowledge, but it has a different cache key and different answer records. An A hit does not imply an AAAA hit. Browser HTTPS-record queries can add a third stream of useful connection information.
“Resolve this host” is an API request. Local policy decides whether it becomes a DNS request, and which resolver receives it.
An answer can be another name
DNS does not map one name to one address. It maps a name, a record type and a class to data. Our ordinary Internet questions use class IN. An The resource records at one owner name with one type and class. DNSSEC signs this set, rather than a whole response message. is the set of records sharing those three keys. A name can have several A records, a separate AAAA RRset, and other data that serves different applications.
The first answer in our example is a CNAME, a canonical-name record. It says that www.example.com is an alias for edge.cdn.example.com. The resolver must now find the requested A records at that target. It can use them if they accompany the response or arrive from cache; otherwise it asks another question. A CNAME chain can cross several zones, and every new target can require another search. Resolvers bound alias chasing to avoid loops and resource exhaustion.
The browser still visits https://www.example.com/. It sends that origin’s hostname in HTTP and validates a certificate for that origin. The DNS target is a way to reach the service, not permission to silently replace the web origin. This is why pointing a CNAME at somebody’s service is only part of configuring a custom domain.
Two RRsets, two independent expiration times
edge.cdn.example.com.192.0.2.80At t = 61 seconds the alias is still fresh, while the address must be refreshed. The CNAME changes the DNS lookup target; the URL and HTTP origin stay www.example.com.
; A small teaching zone, not example.com's live configuration
$ORIGIN example.com.
@ 600 IN SOA ns1.example.com. hostmaster.example.com. (
2026111501 3600 600 86400 120 )
@ 3600 IN NS ns1.example.com.
ns1 3600 IN A 192.0.2.53
www 300 IN CNAME edge.cdn.example.com.
edge.cdn 60 IN A 192.0.2.80
edge.cdn 60 IN AAAA 2001:db8::80A CNAME owner generally cannot have other data, apart from DNSSEC-related records. A zone apex must already have SOA and NS records, so an ordinary CNAME cannot live at that apex. Provider features called ALIAS, ANAME or flattening are usually hosting behaviours that synthesize address answers; they are not a new interpretation of the CNAME wire type. RFC 2181 §10.1 states the alias rules.
| Type | Data | Role in this lookup |
|---|---|---|
| A / AAAA | 32-bit / 128-bit address | Connection destinations, not ports or URLs |
| CNAME | One target name | Follow www to the CDN endpoint |
| NS | Authoritative server name | Find the servers responsible for a zone |
| SOA | Primary server, contact, serial and timers | Zone metadata and negative-cache lifetime |
| MX | Preference and mail-exchanger name | Mail delivery; not part of an ordinary web address lookup |
| TXT | One or more length-prefixed strings | Application-defined text, such as verification and mail policy |
| HTTPS | Priority, target and service parameters | Connection capabilities and hints before connecting |
The service can say more before the handshake
SVCB and its web-specific counterpart HTTPS, defined in RFC 9460 §2.2, publish connection metadata. ServiceMode uses a nonzero priority and can include alpn identifiers such as h2 and h3, an alternate port, IPv4 or IPv6 address hints, and an ech parameter carrying an ECHConfigList. Lower numeric priorities are preferred among usable alternatives.
Address hints can help a client start connection work while address resolution proceeds. They do not convert an HTTPS RR into an A or AAAA record, and a client still follows the address-resolution rules in the specification. The target . in ServiceMode refers to the owner name for endpoint selection. AliasMode, priority zero, redirects SVCB/HTTPS discovery and can be used at an apex without the CNAME coexistence problem.
Unknown service parameters are normally ignorable. The mandatory parameter changes that: every listed key must be present and understood, or the client skips that service record. For example, mandatory=ech makes ECH support a condition of using that endpoint. RFC 9460 §8 also defines automatically mandatory keys; HTTPS makes port and no-default-alpn mandatory to understand whenever present.
The default ALPN set for HTTPS contains http/1.1. Thus alpn=h3 advertises h3 plus that default. Adding no-default-alpn, SvcParamKey 2 with an empty value, removes the default set, leaving h3 in this example. A self-consistent record with this flag must also carry alpn. These rules guide which transports the client attempts; ALPN negotiation still happens in the TLS handshake. See RFC 9460 §7.1.
Open the HTTPS record below. This is a captured cloudflare.com response, separate from the teaching zone. Its ALPN and IP hints are decoded from the actual RDATA. Parameters are a strictly increasing series of 16-bit keys, each followed by a 16-bit length and that many value bytes. Unknown keys must remain parseable even when the client cannot use them.
A real HTTPS answer
ID 0x1234 · RCODE 0 · counts 1 / 2 / 0 / 1
QR=1 opcode=0 AA=0 TC=0 RD=1 RA=1 AD=1 CD=0
Question: cloudflare.com. HTTPS · class 1
answer · cloudflare.com. HTTPS · TTL 300
1 . alpn=h3,h2; ipv4hint=104.16.132.229,104.16.133.229; ipv6hint=2606:4700:0:0:0:0:6810:84e5,2606:4700:0:0:0:0:6810:85e5
Message bytes 32–104; RDATA 44–104
0001000001000602683302683200040008681084e5681085e500060020260647000000000000000000681084e5260647000000000000000000681085e5answer · cloudflare.com. RRSIG · TTL 300
HTTPS; algorithm 13; key tag 34505; signer cloudflare.com.; signature 64 B
Message bytes 105–214; RDATA 117–214
00410d020000012c6afa8de16af7cec186c90a636c6f7564666c61726503636f6d009e3215505e48f869a4e3c11d5d83b470b9303892a5879d0d5a9ba70544d0e5a2b042acc4b19131c847452550a2e44e7afe05582456e770a6752b30774f475d84additional · . OPT · pseudo-RR
UDP 512 B; version 0; DO true; options 0 B
Message bytes 215–225; RDATA 226–225
Decoded 226 bytes. Google Public DNS binary DoH; captured 2026-11-15. Select a record for RDATA.
Bounded offline decoder: up to 4,096 bytes and 1,024 entries. Recognised RDATA is interpreted; other types remain hex. A structurally valid message can still contain semantically unusable records.
Walk once, remember the way
The recursive resolver receives www.example.com. A with recursion desired. It first asks its cache for a usable result. On a miss, it starts from the closest enclosing delegation it already knows. Only a truly cold resolver needs to begin at the root. Root hints supply bootstrap server addresses; they are not a cache of every top-level domain’s contents.
The root does not know our CDN address. It returns a referral: NS records identifying .com’s authoritative servers, with address records that help reach them. The resolver then asks a .com server for the example.com delegation. Finally it asks an example.com authoritative server for www. That authority returns the CNAME. In our zone, the target is also under example.com, so the resolver already knows where to ask for its A RRset.
A CNAME target can cross another zone cut
Our fixed universe keeps edge.cdn.example.com. inside the example.com zone. If the owner instead delegates cdn.example.com., knowing example.com’s servers is only the next starting point. Asking that parent about the target reaches the zone cut and returns a referral, for example cdn.example.com. NS ns1.cdn.example.com. with glue for that in-child nameserver. The resolver then asks the child’s authority for edge.cdn.example.com. A. QNAME minimisation can discover the cut with a cdn.example.com. NS question first. RFC 1034 §4.3.2 describes how an authority returns that referral.
The dots alone do not reveal where the cuts are. If the CNAME instead points to edge.vendor-cdn.net., the resolver searches its cache for that target and the closest enclosing usable delegation. It might begin at vendor-cdn.net, at .net, or at the root. It does not reuse example.com’s authority for an unrelated target. Conversely, a complete fresh alias-and-address answer needs no delegation refresh, even if the cached parent NS records have expired.
A referral’s NS names can create a circular dependency. Suppose example.com’s nameserver is ns1.example.com: to find the server you need its address, but to find its address you seem to need the server. Address records supplied with a delegation so a resolver can reach nameservers whose names fall within the delegated namespace. breaks that cycle. A parent includes necessary address data alongside the delegation. Glue gets the search started; it is not equivalent to an authoritative, signed address answer from the child.
A resolver must also check which extra records it may cache. A referral should not get to introduce arbitrary answers for unrelated domains. Bailiwick rules constrain this trust, and DNSSEC supplies a separate cryptographic check where the chain is secure. The presence of an address in the additional section is never sufficient reason to trust it for every future purpose.
Ask each authority only what it needs
With QNAME minimisation, RFC 9156 §2, the root can receive a question about com rather than the full www.example.com name. The .com server can receive example.com. Only the responsible authority needs www.example.com. The simulator uses NS questions for these delegation-discovery steps. The RFC also permits other QTYPE choices and describes compatibility behaviour for difficult servers.
Minimisation reduces disclosure and can change how many questions a cold walk needs. It does not hide the full name from the recursive resolver. It also does not prevent an authoritative host from learning names for which it is responsible. The useful boundary is narrower: do not teach every ancestor about every leaf your users visit.
Ask again while the cache ages
Model clock: 0 s
com NS86400 s left
example.com NS3600 s left
www CNAME300 s left
edge A60 s left
Cold lookup complete: 96 ms. Answer 192.0.2.80. Resolve again for cache hits.
Each duration bar uses 0–120 ms. Fixed RTTs, serial upstream work, TTLs decremented in whole seconds. Stale policy: retain for 1 hour, wait 40 ms for a failed refresh, return TTL 30. DNSSEC validation and retries are outside this timing model.
A TTL is a lease on reuse
A record’s time to live is an upper bound on ordinary cache reuse, expressed in seconds. When a cache serves an entry, it reports the remaining lifetime, not a fresh copy of the original TTL. Otherwise chains of forwarders could keep data alive forever. A cache may evict entries earlier under memory pressure or impose a shorter local maximum.
Our www CNAME lives for 300 seconds; its A target lives for 60. The .com and example.com delegation entries live much longer. After 61 seconds, a new lookup reuses the delegation and alias and refreshes only the target A. The model therefore takes 8 + 25 = 33 ms, rather than another 96 ms. On a real resolver, fresh CNAME and target address records can also arrive together.
Absence gets cached too. RFC 2308 §5 derives the negative-cache TTL from the smaller of the SOA record’s TTL and its MINIMUM field. In our teaching SOA those values are 600 and 120 seconds for the negative response, so absence can be remembered for 120 seconds. NXDOMAIN means the name does not exist; a NOERROR response without the requested type can instead mean NODATA. A name with TXT but no AAAA is not nonexistent.
Negative caching prevents repeated misses from hammering authorities. It also means that creating a record does not instantly make previous negative answers disappear from the world. A resolver’s SERVFAIL cache is a different mechanism for avoiding repeated failing work; a failure must not be presented as an authoritative proof that a name is absent.
What if the authority disappears?
Serve-stale, RFC 8767 §4, lets a resolver retain expired data and use it under defined failure policy. The resolver still tries to refresh. The stale reply uses a short TTL, with 30 seconds recommended, so downstream caches do not give it a new long life. Operators choose retention limits and failure timers; this simulator uses one hour of retention and a 40 ms failed-refresh wait.
That trades perfect freshness for continuity. During an outage, yesterday’s still-working address can be better than no address. After a planned emergency migration, it can be worse. DNSSEC validity also matters: stale handling must not casually turn an expired signature into authenticated current data. A production resolver combines cache state, validation status, signature times and local policy, while our timing model keeps only the cache and failure decisions.
Caching turns a global delegation walk into a local lookup. Different RRsets expire independently, so a warm lookup often resumes partway down the tree.
An answer has to fit in a packet
So far, an “ask” has been an abstract round trip. Ordinary DNS commonly sends a query as one UDP datagram to port 53 and receives a response from that port. UDP avoids a transport handshake and per-connection state, which suits a small question and answer. It also provides no retransmission, ordering or delivery guarantee. The resolver owns retry policy, server selection and deadlines.
The original DNS UDP response limit was 512 bytes. A server that cannot fit a complete answer can set TC, the truncation bit, so the client retries over a reliable transport, traditionally TCP. DNS over TCP uses the same DNS message with a two-byte, network-order length prefix. A TCP read can contain part of that prefix, part of a message or several messages: the client must frame the stream rather than treating reads as responses.
RFC 7766 §6 makes TCP support a required part of general-purpose DNS implementations and describes connection reuse and pipelining. TCP is not only an emergency mechanism for rare huge answers. Blocking it while allowing UDP can make domains fail selectively as DNSSEC or service metadata enlarges their responses.
A UDP response is either usable, explicitly truncated, or absent
IPv6 minimum MTU 1,280 − IPv6 header 40 − UDP header 8 = 1,232 DNS bytes
EDNS says how much you can receive
EDNS(0), RFC 6891 §6.1.2, adds an OPT pseudo-record that advertises the requester’s UDP payload capacity. Its CLASS field carries that size instead of an ordinary DNS class. It can also carry the DO bit, meaning “DNSSEC OK,” and extensible options. DO requests DNSSEC data; it does not itself perform validation or guarantee that the answer is authenticated.
Advertising 4,096 bytes does not make the network carry a 4,096-byte datagram intact. IP fragmentation may be necessary, and losing one fragment loses the entire datagram. Filters and middleboxes often handle fragments poorly. The DNS Flag Day 2020 operator guidance recommended a 1,232-byte UDP DNS budget: it fits inside IPv6’s 1,280-byte minimum MTU after a basic 40-byte IPv6 header and 8-byte UDP header. Extension headers and tunnels can reduce available space further.
Keeping UDP small can increase TCP fallback while reducing hard-to-diagnose black holes. An EDNS size is a receive advertisement, not a promise that every reply will use that much space. A server can choose a smaller response budget, and a client can switch transports earlier. A complete truncated reply is valid DNS; a physically chopped-off record is malformed input even if TC is set.
A reply must belong to the question
A UDP client matches the reply against its outstanding query: transaction ID, question, and relevant source and destination addresses and ports. The 16-bit ID alone offers only 65,536 possibilities. If an off-path attacker can trigger a lookup and spray forged replies before the authority responds, a small guess space becomes dangerous.
The 2008 Kaminsky cache-poisoning attack made the problem especially urgent by using fresh names to create repeated races and targeting delegation information. RFC 5452 §9.2 recommends unpredictable source ports as well as unpredictable IDs. With 16,384 possible ports, an attacker facing one independent outstanding question must guess among 216 × 214 = 230 combinations before accounting for other checks.
Guess the reply before the authority answers
N = 65,536 × ports × case patterns
0%50%100%
100,000 independent guesses; 65,536 possibilities. Success probability: 78.26%.
One outstanding question; uniform independent guesses with replacement. The attacker must also match the question and relevant endpoint tuple. Case preservation is server-dependent; these 13 bits apply only if the resolver enforces the echoed case of all 13 letters in www.example.com.
The formula assumes independent guesses with replacement against one fixed secret combination. Many simultaneous equivalent outstanding requests can create birthday-style effects, while predictable NAT port rewriting can destroy apparent entropy. These details matter more than merely counting bits in an implementation’s random-number generator.
“0x20 encoding” adds another check by randomising the case of letters in the question, such as wWw.ExAmPle.cOm, and checking the echoed spelling. DNS name comparisons are case-insensitive, but many servers preserve the question’s case. Our hostname has 13 letters, giving up to 13 additional case bits if all are independently randomised and checked. Compatibility and response behaviour limit where this defence works. Neither port randomisation nor case matching authenticates data from an attacker who can observe the query.
Root and TLD services often use anycast: many sites announce routes to the same service address, and BGP routes packets toward one reachable instance according to routing policy. “Nearest” here means a routing choice, not necessarily shortest geographic distance or lowest latency. Anycast spreads load and improves reachability; it does not change DNS delegation or prove an answer correct.
Who gets to read the question?
The café operator can read plain DNS between your laptop and its resolver. That includes the requested name even when the subsequent website connection uses HTTPS. Encryption for the web request begins too late to hide the preceding DNS exchange. Encrypted DNS protects this resolver hop, with several different envelopes around essentially the same DNS message.
DNS over TLS, RFC 7858 §3, runs length-prefixed DNS over a TLS-protected TCP connection, normally on port 853. The client authenticates the resolver’s TLS identity under its configured policy. Reusing the connection amortises TCP and TLS setup over many questions. A visible dedicated port can also make the service easy for a network to identify and block.
DNS over HTTPS, RFC 8484 §4.1, maps a DNS exchange onto HTTP. A POST carries the binary query in a body with media type application/dns-message. A GET places unpadded base64url-encoded DNS bytes in the URI template’s dns parameter. The response body is a binary DNS message, not the JSON interface some resolver vendors also provide. The HTTP status and DNS RCODE describe different layers of success.
DoH clients should set the DNS ID to zero: HTTP already correlates the exchange, and a stable ID lets identical questions share HTTP cache entries (RFC 8484 §4.1).
A successful HTTP response can therefore contain DNS NXDOMAIN. Conversely, an HTTP error need not contain a usable DNS answer at all. HTTP caching also has to respect the DNS response’s lifetimes. Putting an exchange inside HTTP brings established connection management and multiplexing, but it does not make the DNS question disappear from the resolver handling it.
DNS over QUIC, RFC 9250 §4.2, uses a client-initiated bidirectional stream per query/response exchange, normally on UDP port 853. Each DNS message still has a two-byte length prefix. DoQ sets the DNS transaction ID to zero because the stream already identifies the exchange. QUIC loss recovery avoids holding unrelated streams behind a lost byte in one TCP stream, although congestion control and connection-level limits remain shared.
The same 44 bytes, different envelopes
12 34 01 00 00 01 00 00 00 00 00 01 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00 00 29 04 d0 00 00 80 00 00 00
Café operatorCan read the full DNS question and answer.
Recursive resolverSees www.example.com and the client’s network source address.
Authoritative hostsSee questions from the recursive resolver; minimisation reduces disclosure.
Plain DNS selected. Choose DoH GET to encode this query as an unpadded base64url dns parameter.
Generated offline. DoH endpoint shown as resolver.example; no request is made. DoH GET encoding with ID 0: AAABAAABAAAAAAABA3d3dwdleGFtcGxlA2NvbQAAAQABAAApBNAAAIAAAAA.
Encryption moves the trust boundary
With DoT, DoH or DoQ, the café usually sees the resolver endpoint, traffic sizes and timing, but not the plaintext DNS question on that connection. The recursive resolver still sees the question and the client’s source address, which may be a NAT or VPN exit. Its ordinary upstream queries can still be plaintext. QNAME minimisation helps there, but is a separate mechanism.
Oblivious DoH, RFC 9230 §4, adds a proxy and encrypts the query for a target resolver using HPKE. The proxy sees the client address without the plaintext question; the target decrypts the question without receiving the client’s direct source address. This split assumes the parties do not collude and does not eliminate timing correlation. The RFC is Experimental, and availability depends on deployment.
After DNS, the café can still see the IP address your browser connects to. A dedicated address can identify the service; a shared CDN address may narrow it less. Without Encrypted ClientHello, the TLS server-name extension can reveal the hostname as well. ECH, now specified in RFC 9849 §6, encrypts an inner ClientHello using a server configuration that HTTPS records can distribute. Encrypted DNS and ECH protect complementary disclosures; neither hides all traffic metadata.
The resolver’s privacy policy, logging behaviour and jurisdiction still matter because encryption does not prevent an endpoint from recording what it receives. On managed networks, local names and split-horizon answers may require a designated resolver. An encrypted public service can give a different answer than an internal service, or no answer for an internal name. Choosing the endpoint is part of choosing whose view of the namespace you use.
Encrypted DNS hides the resolver conversation from the access network. It does not hide the name from that resolver or authenticate authoritative data by itself.
Twelve bytes, then names and records
All of these transports need an actual DNS message. RFC 1035 §4.1 defines a 12-byte header followed by question, answer, authority and additional sections. Multibyte integers use network byte order, most significant octet first. Counts tell the parser how many entries to read in each section; they are counts of questions or resource records, not byte lengths.
The first two bytes are the transaction ID. The next two hold flags and the base response code. QR distinguishes query from response. Opcode selects the operation, with zero meaning a standard query. AA marks an authoritative answer; RA says recursion is available, and RD requests it. A recursive resolver answering from validated cache is not thereby authoritative for the name.
TC signals truncation. AD, added by DNSSEC, indicates authenticated data under the resolver’s validation policy; CD lets a client request that the recursive resolver not withhold data solely because validation failed. The remaining reserved Z bit must be zero. The four-bit RCODE includes NOERROR=0, SERVFAIL=2 and NXDOMAIN=3; EDNS can extend it. Registry assignment procedures and the historical layout are discussed in RFC 6895 §2.
The 16-bit flags word · equal width per bit
- QR · 1 bit
- Query or response
- Opcode · 4 bits
- Operation
- AA · 1 bit
- Authoritative
- TC · 1 bit
- Truncated
- RD · 1 bit
- Recursion desired
- RA · 1 bit
- Recursion available
- Z · 1 bit
- Reserved: zero
- AD · 1 bit
- Authenticated data
- CD · 1 bit
- Checking disabled
- RCODE · 4 bits
- Response code
The name is not a zero-terminated string
A question contains QNAME, QTYPE and QCLASS. A QNAME is a sequence of labels, each starting with its one-byte length, terminated by the zero-length root label. In our hostname the first byte is 03, followed by the three ASCII bytes for www; 07 introduces example; 03 introduces com. The final 00 is the root, not a C-string terminator that can replace the length checks.
Each ordinary label has at most 63 octets. The full expanded name, including length octets and the root label, has at most 255 octets. DNS wire labels can contain octets outside hostname syntax; an application hostname normally follows the letter-digit-hyphen rules, with internationalised names encoded as IDNA A-labels. Our query input deliberately accepts ASCII hostnames, optional final dot, and the root itself.
Try AAAA, remove OPT, or set CD. The builder updates the counts, QTYPE and additional section; it does not simply change a label next to unchanged sample bytes. The fixed transaction ID makes the example easy to compare with later frames. A real UDP client chooses an unpredictable ID.
Build a wire-format question
12 34 01 00 00 01 00 00 00 00 00 01 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00 00 29 04 d0 00 00 80 00 00 00
Transaction ID12 34
16 bits echoed by the response. A real UDP client randomises it.
Flags01 00
RD=1 asks for recursion. QR=0 means query; opcode=0 is QUERY.
Section counts00 01 00 00 00 00 00 01
Counts for questions, answers, authority records and additional records. OPT counts as additional when enabled.
Question name03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00
Length-prefixed labels; the zero-length root label terminates the name.
Question type and class00 01 00 01
QTYPE selects A (1), AAAA (28) or HTTPS (65); class 1 is IN.
OPT pseudo-record00 00 29 04 d0 00 00 80 00 00 00
Root owner; type 41; UDP size 1232; DO=1 requests DNSSEC records; no option data.
44 bytes ready. Open a field to connect its bytes to its meaning.
Fixed ID 0x1234 for inspection. No packet is sent. This input accepts hostnames in LDH syntax; DNS wire labels can contain a broader range of octets.
Every resource record has one outer shape
An RR starts with NAME, then TYPE (2 bytes), CLASS (2), TTL (4), RDLENGTH (2) and RDATA (RDLENGTH bytes). The name is variable-length and may be compressed where allowed. Type determines the RDATA grammar: four address bytes for A, sixteen for AAAA, a domain name for CNAME, and two names plus five 32-bit numbers for SOA.
The parser must use RDLENGTH to bound that grammar. Reading a CNAME name successfully is not enough if it consumed three bytes of a two-byte field or left unexplained bytes behind. A name pointer inside the field may refer outside it, but the pointer’s own two bytes must fit inside the field. Unknown RR types can be skipped by length without inventing an interpretation.
OPT keeps the outer RR shape but repurposes fields: root owner, type 41, advertised UDP size in CLASS, and extended RCODE, EDNS version and flags in the TTL position. It belongs in additional and is not ordinary cacheable zone data. Our OPT advertises 1,232 bytes, sets DO, and has zero bytes of option RDATA. Changing the payload budget does not add padding to the query.
Read the outer lengths first, then apply the type’s inner grammar. The transport envelope does not make malformed DNS safe to parse.
Follow the pointers without getting lost
Responses repeat names frequently. Every A record in an RRset has the same owner; a CNAME target may become the next record’s owner. Sending each name again wastes space, especially under the old 512-byte UDP budget. DNS compresses a repeated suffix with a two-byte pointer, described in RFC 1035 §4.1.4.
A pointer begins with the high two bits 11. The remaining 14 bits are an offset from the first byte of the DNS message, not the UDP header and not the current name. Thus c0 0c points to offset 12, where our question name starts. A name can be ordinary labels, a pointer, or ordinary labels followed by a pointer to an earlier suffix.
03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00
w w w e x a m p l e c o m root
c0 0c → 11000000 00001100
^^ 14-bit offset = 12
pointer tagFollowing a pointer changes where the parser reads name labels; it does not change where the enclosing record ends. Keep two positions: a cursor that follows the compressed name, and the position immediately after its first pointer, where the outer parser resumes. Failing to separate them makes the next TYPE or RDLENGTH come from the wrong part of the message.
Every hop needs bounds checks. The pointer must fit in its current field, its target must be a prior occurrence within the message, and the expanded name must still satisfy the 255-octet limit. Track visited offsets to reject cycles. A backward pointer can still loop by pointing to the label sequence that contains it. The two leading patterns 01 and 10 are not ordinary label lengths and must not be accepted as 64- or 128-byte labels.
RFC 9267 §2 documents real implementation failures caused by pointer mishandling. The decoder here rejects self-pointers, forward pointers, cycles, truncated labels, impossible RDATA lengths and unsupported label tags. It also bounds the user’s input and declared entry counts, so a short malicious header cannot induce unbounded parsing work.
Decode a captured DNS message
ID 0x1234 · RCODE 0 · counts 1 / 2 / 0 / 1
QR=1 opcode=0 AA=0 TC=0 RD=1 RA=1 AD=0 CD=0
Question: www.wikipedia.org. A · class 1
answer · www.wikipedia.org. CNAME · TTL 20568
dyna.wikimedia.org.
Message bytes 35–63; RDATA 47–63
0464796e610977696b696d65646961c01aanswer · dyna.wikimedia.org. A · TTL 180
185.15.59.224
Message bytes 64–79; RDATA 76–79
b90f3be0additional · . OPT · pseudo-RR
UDP 512 B; version 0; DO true; options 0 B
Message bytes 80–90; RDATA 91–90
Decoded 91 bytes. Google Public DNS binary DoH; captured 2026-11-15. Select a record for RDATA.
Bounded offline decoder: up to 4,096 bytes and 1,024 entries. Recognised RDATA is interpreted; other types remain hex. A structurally valid message can still contain semantically unusable records.
The CNAME response was captured for www.wikipedia.org and carries an address for dyna.wikimedia.org. The referral came directly from a.root-servers.net for com. The NXDOMAIN fixture asks for a name under the reserved invalid TLD and includes denial data and an SOA. These captures preserve the received DNS bytes, including compression choices and TTLs, rather than reconstructing what we think a server would have sent.
Some recognised types get detailed decoding; other RDATA stays hex. That distinction is deliberate: a parser can establish structural boundaries without claiming that every record is semantically usable. For example, an HTTPS client also has to interpret mandatory keys, service priorities and supported protocols before connecting. Seeing a well-formed parameter is not equivalent to accepting that service configuration.
A TC-marked message still has to be structurally valid. The decoder never reads past its byte array to “finish” a cut-off record. A client receiving a valid TC response uses it as a reason to obtain a complete answer over another transport. An offline inspection tool should surface both facts separately: whether the message can be parsed, and whether the response says more data was omitted.
Verify the answer, not the messenger
Strict parsing and randomised queries stop several attacks, but they do not let a resolver prove who published an address. DNSSEC signs RRsets. A resolver with an authenticated key can verify an answer even when an untrusted network carries it. DNSSEC does not encrypt the question, hide the answer, or prove that the website at that address is safe.
A DNSKEY record publishes a zone’s public key. An RRSIG identifies the covered type, algorithm, original TTL, signature validity interval, key tag and signer, followed by the signature bytes. A parent’s DS record contains a digest of a child DNSKEY. Starting from a configured root trust anchor, a validator can authenticate the root DNSKEY set, the parent’s delegation data and the child’s keys, and eventually the answer’s signature.
Keys often have separate roles: a key-signing key signs the DNSKEY RRset, while a zone-signing key signs ordinary data. Some deployments use one combined signing key. A key tag is a compact 16-bit identifier for finding candidate keys, not a collision-resistant fingerprint. A validator still needs to match and verify the actual key material.
The root key changed in 2026
As checked for this dive on 15 November 2026, IANA’s rollover status reports KSK-2024, key tag 38696, signing since 11 October 2026. KSK-2017, tag 20326, is the outgoing key, not the current signing KSK. The published schedule places its revocation in January 2027 and removal in March 2027; those are planned operational events. Validators should use maintained trust-anchor data and rollover mechanisms, not copy a permanent key tag from an explainer.
The root’s key algorithm is distinct from the algorithm used in the following fixture. Our captured cloudflare.com A RRset uses algorithm 13: ECDSA P-256 with SHA-256, specified in RFC 6605 §4. Its DNSKEY contains 32-byte x and y coordinates. Its signature is 32-byte r followed by 32-byte s, matching the raw ECDSA signature format WebCrypto accepts; it is not an ASN.1 DER sequence.
Verify a signed A RRset with ECDSA P-256
The computation below verifies the last signature using the captured DNSKEY. The earlier delegation links are shown for context; they are not validated by this lab.
cloudflare.com. 300 IN A 104.16.132.229 cloudflare.com. 300 IN A 104.16.133.229 A; algorithm 13; key tag 34505; signer cloudflare.com.; signature 64 B
Signature result: waiting for verification.
SHA-256(owner name || DNSKEY RDATA):
Digest appears here after verification.Ready. Captured 15 November 2026 through Google Public DNS; signature validity is checked at the capture time.
Original TTL, uncompressed lowercase owner and signer, and sorted A RDATA form the signed bytes. The digest is for the matching signing DNSKEY; it is not a claim that a parent publishes this DS.
What exactly was signed?
The signature covers the RRSIG fields preceding the signature itself, including the signer name, followed by the canonical RRset. RFC 4034 §6 defines canonical form: names are uncompressed with lowercase ASCII letters, records use the RRSIG’s original TTL, and RRset members are sorted by canonical RDATA. The ordinary cached TTL can decrease without breaking the signature because validation reconstructs the original value.
The lab rebuilds those bytes from the captured A records, imports the matching DNSKEY as a P-256 public key, and calls crypto.subtle.verify(). It also computes SHA-256 over the canonical DNSKEY owner name concatenated with DNSKEY RDATA. That is the DS digest input. The resulting DS fields include key tag, DNSKEY algorithm, digest type 2 and the digest bytes.
This proves that the RRset is consistent with that captured key. The key itself still needs authentication through the parent, and a complete validator must check owner names, algorithms, key flags, delegation status, signature times and denial proofs. The fixture is checked at its recorded capture time: an archived signature should not suddenly be described as currently valid after its expiration date.
Recover the wildcard from Labels
The RRSIG Labels field counts labels in the original signed owner, excluding the root and a wildcard label. An ordinary www.example.com. owner has Labels=3. If a zone instead synthesises that answer from *.example.com., the received owner still has three labels but the RRSIG has Labels=2. The validator takes the rightmost two labels and prepends *., recovering the signed owner *.example.com. for canonicalisation. Labels greater than the received owner’s count is invalid. RFC 4034 §3.1.3 defines this field. The validator must also prove that no exact or closer match displaced the wildcard; verifying its signature alone is insufficient.
Absence needs a proof too
Without authenticated denial, an attacker could replace any answer with “does not exist.” NSEC records link names in a signed ordering and describe which types exist at an owner. That lets a validator establish that a queried name falls in a gap or that a requested type is absent. NSEC3, RFC 5155 §3, uses hashed owner names and adds more complex denial rules. Hashing is not strong confidentiality for predictable names; offline guessing remains possible.
; Real NSEC records in the captured .invalid NXDOMAIN response
intuit. 85182 IN NSEC investments. NS DS RRSIG NSEC
. 86294 IN NSEC aaa. NS SOA RRSIG NSEC DNSKEY ZONEMDThe NXDOMAIN fixture supplies a concrete proof for dns-dive-no-such-name.invalid.. Its root-zone NSEC records include the two shown above. In canonical name order, intuit. < invalid. < investments., so the second-level target lies below a nonexistent invalid. label: there is no such TLD or subtree to search. The other interval, from . to aaa., also covers *., excluding a root wildcard that could supply an answer. Both NSEC RRsets need authenticated RRSIGs before those intervals constitute a trusted denial, as required by RFC 4035 §5.4. The capture includes those signatures.
The listed types come from each NSEC bitmap. At intuit., the set is NS, DS, RRSIG and NSEC; this describes the interval’s owner, not the missing name. An exact-owner NSEC bitmap can instead establish NODATA by omitting the requested type. NXDOMAIN additionally requires excluding the applicable wildcard, which is why this captured proof uses two intervals.
A validated chain may establish a secure answer, a securely proven unsigned delegation, or a bogus result that fails validation. An unsigned child below a properly proven insecure delegation is different from a child whose expected signature is missing. A validating resolver generally withholds bogus data and returns SERVFAIL, unless the client’s CD request and resolver policy permit delivery for client-side checking.
Most browser and OS stubs rely on a recursive resolver to validate. AD is that resolver’s assertion about authentication, not a cryptographic proof attached to the flag itself. A stub that trusts AD needs a trusted resolver and a protected path to it, or equivalent local assurance. A forged AD bit on plain DNS from an untrusted network cannot replace doing validation.
A signature is useful only after you authenticate its key. DNSSEC makes that dependency explicit with DS records and a root trust anchor.
The lookup leaves the laptop
The laptop now has a DNS query byte array. To send it using ordinary DNS, its network stack wraps that array in UDP and IP headers, then in the link layer used on the next hop. The destination IP belongs to the recursive resolver; the link-layer destination usually belongs to the next-hop router when that resolver is off-link. A router changes link-layer framing along the path while forwarding the IP packet.
The figure reconstructs both directions of our teaching exchange. It uses documentation IP addresses and locally administered MAC addresses, with correct IPv4 and UDP checksums and Ethernet CRC-32. The response contains the alias and its final A record in one message. The resolver may have needed two upstream exchanges to assemble that single client response.
A bare A question for www.example.com takes 33 DNS bytes. UDP adds 8 bytes; a minimal IPv4 header adds 20; an untagged Ethernet header adds 14 and its frame check sequence adds 4. The frame therefore occupies 79 bytes, including FCS. The Ethernet preamble and start delimiter add 8 byte-times, and the mandatory gap adds 12 more, giving 99 byte-times of link occupancy for this frame. These frames are large enough that minimum-payload padding is unnecessary.
Every byte of the café lookup
33 DNS bytes + 46 framing bytes = 79-byte Ethernet frame
0000 02 00 00 00 00 01 02 00 00 00 00 0a 08 00 45 00 0010 00 3d 12 34 40 00 40 11 a4 3c c0 00 02 0a c0 00 0020 02 35 cf 08 00 35 00 29 4f 8e 12 34 01 00 00 01 0030 00 00 00 00 00 00 03 77 77 77 07 65 78 61 6d 70 0040 6c 65 03 63 6f 6d 00 00 01 00 01 a6 44 4c 77
Query frame selected. Choose a layer to inspect its fields and byte offsets.
Constructed, checksum-valid teaching frames with documentation IPs and locally administered MACs. Ethernet view beyond the access point; Wi-Fi has different link framing. Untagged Ethernet; FCS included, 8-byte preamble/SFD and 12-byte inter-frame gap excluded from the hex.
The UDP length includes the UDP header and DNS payload. Its checksum also incorporates an IP pseudo-header containing source, destination, protocol and UDP length, tying the datagram to its endpoints. The IPv4 header checksum covers only that header. The Ethernet FCS detects accidental frame corruption on one link. None of these checks is a substitute for the DNSSEC signature or a transport authentication mechanism.
The actual café hop uses 802.11, with different headers, acknowledgements, retransmissions and airtime costs. The Ethernet view is useful beyond the access point, where the same DNS payload may travel over wired infrastructure. A VPN or encrypted DNS session would add different envelopes and hide the plaintext DNS bytes from this observation point. Framing depends on where you capture.
Inside the recursive service
A resolver typically separates several kinds of cached knowledge: message or answer data, RRsets, delegation and nameserver information, validation state, and infrastructure information such as server reachability and RTT estimates. Exact structures vary. An RRset cache can be indexed by canonical owner name, type and class, with expiration metadata; it must also keep the security context needed to avoid reusing unauthenticated data as authenticated data.
Concurrent requests for the same missing RRset can share in-flight work instead of starting independent root walks. Resolvers cap outstanding requests, retries and alias depth to limit overload and malicious dependency chains. Their upstream server-selection policy balances measured responsiveness, failures and available alternatives. Those runtime decisions explain why a production trace can have parallel questions or alternate nameservers rather than our model’s tidy serial sequence.
Prefetch refreshes popular records shortly before expiry, often triggered by demand near the end of a TTL. It can keep common answers warm at the cost of more upstream traffic. Serve-stale keeps expired data for a different purpose: continuity when refresh fails. A short TTL can improve change propagation while increasing refresh frequency; it does not mean that every visitor causes an authoritative query.
Anycast adds another cache boundary. Two requests to the same public resolver IP may reach different sites after a route change. Their caches need not have identical contents or ages. An address identifies the service from the client’s point of view, while routing, load balancing and resolver deployment decide which process performs the work. The DNS protocol does not promise one worldwide shared cache behind that address.
The second visit
You type the same name again. A reusable connection might avoid resolution altogether. Otherwise the browser may use a host-cache entry, the OS may return a local cached result, or the recursive service may answer from still-fresh RRsets. If only the A TTL expired, the resolver asks the known authority for the target address. If the whole delegation path expired, it learns the route again.
The root did not push an address into your laptop. A chain of bounded claims did the work: local resolution policy chose a service, delegations located authority, records supplied aliases and addresses, TTLs bounded reuse, and optional signatures authenticated the data. Finally the browser has candidates it can connect to. DNS has completed its job; establishing a working, authenticated web connection is the next system’s problem.
The address is the output of a search through authority and time-bounded caches. The wire carries that result as ordinary records, protected by whichever transport and validation mechanisms the client actually uses.
End of DNS · 10 levels, Idea to Machine
Where to next
Next in Web and networking · 02 of 12
HTTPS, before the first GET
One round trip to agree on keys, prove a server’s identity and hide an HTTP request. Follow TLS 1.3 from the first visible byte to the silicon doing the encryption.
Practical notes
Check whether a site uses HTTP/3
Check client support, inspect HTTP/3 advertisements, then confirm the actual connection protocol with curl or browser DevTools.
Debug DNS with dig
Compare recursive and authoritative answers, inspect status and TTLs, and distinguish DNSSEC signals from local validation.