Before your browser can open a single connection, it has to turn a name into an address. DNS does that billions of times a second, and when it fails, everything fails with it.
DNS is the oldest and most underestimated part of the web stack. It is a global, distributed database without a central server, answered mostly from caches, carried mostly over UDP, and still largely unencrypted. "It's always DNS" is a running joke among operations engineers for a reason: when a whole platform goes down, DNS is often involved.
This article takes DNS apart with real measurements of this site, farschidnia.de: the hierarchy from the root to the answer, the resolvers that do the work, the records you need, how caching and TTLs really behave, how fast a lookup is, how DNS gets attacked and how DNSSEC and encrypted DNS defend it. It continues the networking series after How HTTPS Really Works.
1. What DNS Does
Computers connect to IP addresses like 92.205.105.140. People remember names like farschidnia.de. The Domain Name System maps one to the other, and much more: where to deliver mail, which certificate authorities may issue certificates, which protocols a server speaks.
DNS was designed by Paul Mockapetris in 1983 and standardised in RFC 1034 and RFC 1035 in 1987. Before that, every computer on the network had a copy of one text file, HOSTS.TXT, maintained centrally and downloaded regularly. That file still exists today as /etc/hosts, and it still wins over DNS on your machine.
The design goals of 1983 still shape DNS today:
- Distributed: no single server knows all names. Each organisation answers for its own part.
- Hierarchical: names are read from right to left, from general to specific.
- Cached: almost every answer comes from a cache, not from the source.
- Fast and small: a question and its answer usually fit into one UDP packet each.
2. The Hierarchy: From the Root to the Answer
A domain name is a path in a tree, read from right to left. www.farschidnia.de. really ends with a dot, the root:
. root
└── de. top-level domain (TLD), run by DENIC
└── farschidnia.de. zone of the domain owner
└── www a name inside that zone
Each level only knows who is responsible for the level below. This is called delegation. You can walk the path yourself by asking each server directly. The flag +norec tells the server "don't look it up for me, just tell me what you know":
dig @a.root-servers.net farschidnia.de A +norec
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 6, ADDITIONAL: 13
de. 172800 IN NS a.nic.de.
de. 172800 IN NS l.de.net.
de. 172800 IN NS s.de.net.
The root does not know the address. It answers with a referral: "ask the servers of .de". Next step:
dig @a.nic.de farschidnia.de A +norec
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 1
farschidnia.de. 86400 IN NS ns49.domaincontrol.com.
farschidnia.de. 86400 IN NS ns50.domaincontrol.com.
Again a referral, now to the name servers of my DNS provider. Last step:
dig @ns49.domaincontrol.com farschidnia.de A +norec
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
farschidnia.de. 600 IN A 92.205.105.140
The aa flag means authoritative answer: this server is the source of truth for the zone. Three questions, three servers, one address.
The root servers
There are 13 root server names, a.root-servers.net to m.root-servers.net, run by 12 independent organisations. Thirteen sounds fragile, but each name is served by many machines worldwide through anycast: the same IP address is announced from many places, and the network routes you to the nearest one. In total there are about 2,000 root server instances. The query above took 21 ms from Germany, because one of them is close.
Glue records
There is a chicken-and-egg problem hidden here. If the name servers of example.com were ns1.example.com, you would need to resolve example.com to find out how to resolve example.com. The parent zone solves this by including the IP addresses of such name servers directly in the referral. These are glue records, and they are why the root's answer above carried extra records in the ADDITIONAL section.
3. Resolvers: Who Does the Work
Your laptop does not walk the tree itself. Three kinds of DNS software share the work:
| Role | What it does | Example |
|---|---|---|
| Stub resolver | Asks one server and waits for the final answer | Your operating system |
| Recursive resolver | Walks the tree, caches everything | Your router, ISP, 1.1.1.1, 8.8.8.8 |
| Authoritative server | Answers for its own zone only | Root, .de, ns49.domaincontrol.com |
A lookup from the browser travels through several caches before anything goes over the network:
Browser cache hit? answer, done
└─> OS cache hit? answer, done
└─> Router hit? answer, done
└─> Recursive resolver hit? answer, done
└─> root ─> TLD ─> authoritative (full miss only)
Each layer answers from its cache if it can. The full walk through root, TLD and authoritative servers happens only when no cache along the way has the answer, which on a busy resolver is rare. The .de delegation, for example, is cached for two days (172,800 seconds), so a resolver asks the root about .de once every two days, not once per user.
Public resolvers such as Cloudflare's 1.1.1.1, Google's 8.8.8.8 and Quad9's 9.9.9.9 also use anycast, which is why they answer from nearby even though their address is the same worldwide.
Two caches are easy to forget:
/etc/hostsis checked before DNS. A forgotten entry there explains many "it works on my machine" mysteries.- Application caches. The JVM, for example, keeps its own cache that ignores the record's TTL: OpenJDK caches successful lookups for 30 seconds (
networkaddress.cache.ttl; with the old security manager, forever) and failed ones for 10 seconds. A Java service may keep talking to an old address after a DNS change, or keep failing after a record has been fixed.
4. The Records You Need
A DNS zone is a list of resource records. Each has a name, a TTL, a class (always IN for internet), a type and data. These are the types you will meet in practice:
| Type | Meaning | Example |
|---|---|---|
| A | IPv4 address | farschidnia.de. A 92.205.105.140 |
| AAAA | IPv6 address | example.com. AAAA 2606:2800:... |
| CNAME | Alias to another name | blog.example.com. CNAME example.github.io. |
| MX | Mail server, with priority | farschidnia.de. MX 0 smtp.secureserver.net. |
| TXT | Free text: SPF, verification tokens | "v=spf1 include:secureserver.net -all" |
| NS | Name servers of the zone | farschidnia.de. NS ns49.domaincontrol.com. |
| SOA | Zone metadata (serial, timers) | see section 6 |
| CAA | CAs allowed to issue certificates | example.com. CAA 0 issue "letsencrypt.org" |
| HTTPS | Connection hints: HTTP/3, ECH keys | example.com. HTTPS 1 . alpn="h3,h2" |
| PTR | Reverse lookup: address to name | 140.105.205.92.in-addr.arpa. PTR ... |
You can query any of them with dig:
dig +noall +answer farschidnia.de MX
dig +noall +answer farschidnia.de TXT
farschidnia.de. 3276 IN MX 0 mailstore1.secureserver.net.
farschidnia.de. 3276 IN MX 0 smtp.secureserver.net.
farschidnia.de. 546 IN TXT "v=spf1 include:secureserver.net -all"
Rules that catch people out
- No CNAME at the zone apex.
example.comitself cannot be a CNAME, because a CNAME must be the only record for its name, and the apex always needs SOA and NS records. DNS providers work around this with their own "ALIAS" or "flattening" features. - The trailing dot matters in zone files.
www.example.com.is a full name. Without the dot, many tools append the zone name and you getwww.example.com.example.com. - Wildcards answer for everything. A record for
*.farschidnia.demakes every name below the domain resolve. You can see it:dig doesnotexist.farschidnia.dereturns the same address as the domain itself. Convenient, but it also means typos and forgotten subdomains never fail loudly.
The HTTPS record
The newest useful type is HTTPS (and its general form SVCB, RFC 9460, 2023). It tells the browser, in the same DNS lookup, that a server supports HTTP/3 and which keys to use for Encrypted Client Hello. Without it, a browser learns about HTTP/3 only from the first HTTP response (the Alt-Svc header) and uses it on the next connection. With it, the very first connection can go straight to QUIC, saving round trips, the topic of Round Trips, TCP and QUIC.
5. Reading a dig Answer
dig prints a lot, and every line means something. Here is a full answer from Cloudflare's resolver, shortened slightly:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12952
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;farschidnia.de. IN A
;; ANSWER SECTION:
farschidnia.de. 591 IN A 92.205.105.140
;; Query time: 19 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
Line by line:
- status: NOERROR. The name exists.
NXDOMAINmeans the name does not exist;SERVFAILmeans the resolver could not get an answer, often a broken delegation or a DNSSEC failure. - id: 12952. A random 16-bit number that matches the answer to the question. It matters for security (section 9).
- flags.
qr= this is a response,rd= recursion desired (the client asked the resolver to do the work),ra= recursion available. An authoritative server addsaa; a validated DNSSEC answer addsad. - EDNS, udp: 1232. The largest UDP answer the resolver accepts (section 7).
- 591. The remaining TTL in seconds. The authoritative server says 600; Cloudflare got the record 9 seconds earlier and counts down.
- Query time: 19 msec. One round trip to a nearby resolver that had the answer cached.
6. TTL and Caching
Every record carries a time to live: how many seconds a resolver may keep it in its cache. The TTL is the most important and most misunderstood number in DNS.
The records of this site show typical values:
| Record | TTL at the source | Meaning |
|---|---|---|
.de delegation (from the root) | 172,800 s | 2 days |
farschidnia.de NS (from .de) | 86,400 s | 1 day |
farschidnia.de NS (own zone) | 3,600 s | 1 hour |
farschidnia.de A | 600 s | 10 minutes |
The trade-off is simple:
- Long TTL: fewer queries, faster answers from cache, less load, more resilience if the authoritative servers are briefly down.
- Short TTL: changes take effect quickly, but more lookups miss the cache and pay the full latency.
There is no such thing as "DNS propagation". Nothing is pushed anywhere. Resolvers simply keep old answers until their TTL expires and then ask again. A record with a TTL of one day can be cached, and served, for up to one day after you change it.
How to move a server without downtime
- Days before the move, lower the TTL of the record, for example from 3,600 to 60 seconds. Wait at least the old TTL, so every cache has picked up the short one.
- Change the record to the new address. Within about a minute, most clients use the new server.
- Keep the old server running for a while; some clients and application caches ignore TTLs.
- When everything is stable, raise the TTL again.
Negative caching
"This name does not exist" is cached too (RFC 2308). The duration comes from the zone's SOA record:
farschidnia.de. SOA ns49.domaincontrol.com. dns.jomax.net. (
2026051202 ; serial: version of the zone
28800 ; refresh: secondaries check for changes (8 h)
7200 ; retry: if that fails, try again after (2 h)
604800 ; expire: secondaries give up after (7 days)
600 ) ; minimum: TTL for negative answers (10 min)
This explains a classic: you look up api.example.com before creating it, get NXDOMAIN, create the record, and it still "does not exist" for up to the negative TTL. The resolver is not broken; it is doing exactly what the zone told it to.
7. DNS on the Wire: UDP, TCP and Size Limits
DNS normally runs over UDP on port 53. A question is one packet, the answer is one packet, there is no handshake. That is why a cached lookup costs exactly one round trip.
The original standard limited UDP answers to 512 bytes. Modern answers, with IPv6 addresses, DNSSEC signatures or many records, are often bigger. Two mechanisms handle that:
- EDNS(0) (RFC 6891) lets the client announce a larger buffer. Since the "DNS Flag Day" in 2020, the recommended size is 1232 bytes, exactly what the Cloudflare answer above shows. It avoids IP fragmentation, which many networks drop.
- TCP fallback. If an answer does not fit, the server sets the TC (truncated) flag, and the client repeats the question over TCP on port 53. That costs a TCP handshake extra, but it always works. Blocking TCP port 53 in a firewall therefore breaks DNS in subtle ways: small answers work, large ones fail.
8. How Fast Is DNS?
DNS is the first step of every new connection, so its latency adds directly to page load time. From my desk in Germany:
| Situation | What happens | Time |
|---|---|---|
| Browser or OS cache hit | No network at all | ~0 ms |
| Resolver cache hit | One round trip to the resolver | 19–25 ms |
| Full resolution | Resolver asks root, .de and authoritative | resolver RTT + 21 + 25 + 18 ms |
A full walk of this domain costs about 64 ms on top of the round trip to the resolver, and much more for a user far from the servers. In practice the root and .de answers are almost always cached at the resolver, so most misses only pay for the last step.
Ways to keep DNS off the critical path:
- Fewer hostnames. Every extra domain on a page (fonts, analytics, CDN, API) costs its own lookup plus a TCP and TLS handshake.
dns-prefetchandpreconnect.<link rel="preconnect" href="https://api.example.com">resolves and connects early, while the browser is still parsing HTML.- Sensible TTLs. A TTL of 60 seconds on a busy site means many cache misses; 5 to 60 minutes is a good default for records that rarely change.
- Fast authoritative DNS. Providers with anycast name servers answer the last step from nearby.
The bigger picture of why each of these waits matters more than bandwidth is in Latency Is the New Bandwidth.
9. Attacks on DNS
Classic DNS has no encryption and no authentication. A resolver accepts the first answer that matches its question. That design invites several attacks.
Spoofing and cache poisoning
An attacker who can send packets to a resolver can try to answer before the real server does. To be accepted, the fake answer must match the question, the 16-bit query ID and the resolver's source port.
In 2008 Dan Kaminsky showed how practical this was: by asking for many random, non-existent subdomains (a1.bank.com, a2.bank.com, ...), an attacker gets unlimited attempts, and each fake answer can carry a forged referral for the whole domain. A poisoned resolver then sends every user to the attacker's server. With only 65,536 possible IDs, this took seconds.
The emergency fix, rolled out by all vendors at once, was source port randomisation: the resolver picks a random port for each query, which multiplies the guessing space by tens of thousands. Some resolvers also randomise the upper and lower case of the query name (fArScHiDnIa.De) and check that the answer echoes it. These measures make blind spoofing very hard, but they are statistics, not proof. The real fix is DNSSEC.
Other attacks
- Hijacking at the registrar. If someone takes over the account where the domain is registered, they can change the name servers and control everything. Use two-factor authentication and the registrar lock.
- Amplification DDoS. A small DNS question with a forged source address produces a much larger answer that hits the victim. Open resolvers make this possible; well-run resolvers only answer their own users and rate-limit.
- Attacks on DNS providers. In October 2016 the Mirai botnet flooded the DNS provider Dyn, and sites like Twitter, GitHub and Netflix became unreachable for hours in parts of the world, although their own servers were fine.
10. DNSSEC: Signatures for DNS
DNSSEC adds digital signatures to DNS. It does not encrypt anything; it lets a resolver verify that an answer really comes from the zone owner and was not changed. If you have read the HTTPS article, the design will look familiar: it is a chain of trust from a root key, just like certificates.
- Each zone signs its records with its own key. The signatures are stored as RRSIG records, the public keys as DNSKEY records.
- The parent zone vouches for the child's key with a DS record (a hash of the child's key), signed by the parent.
- The root zone has been signed since 2010. Its key is built into every validating resolver.
So a validating resolver checks: root key → signature on the .de DS record → .de key → signature on the farschidnia.de DS record → key of the zone → signature on the A record. If anything does not verify, the answer is SERVFAIL, and the client gets nothing rather than something forged.
You can see which zones are signed:
dig +noall +answer de DS
dig +noall +answer farschidnia.de DS
de. 30975 IN DS 26755 8 2 F341357809A5954311CCB82ADE114C6C...
.de is signed (algorithm 8 is RSA/SHA-256). farschidnia.de has no DS record, so it is not signed, and validating resolvers return its answers without the ad (authenticated data) flag. That is the norm, not the exception: DNSSEC is widely deployed at the top of the tree, but only a minority of individual domains are signed.
Why so few? DNSSEC adds operational risk. Keys must be rolled over, signatures expire, and a mistake makes the whole domain unreachable for every validating resolver. Many providers now offer one-click DNSSEC with automatic key management, which removes most of that risk. If your provider offers it, turn it on.
11. Privacy: Who Sees Your Queries
Classic DNS is plain text. Everyone on the path, the Wi-Fi operator, your ISP, any network in between, can see every name you look up, even when the website itself is loaded over HTTPS. Three protocols encrypt the connection between your device and the resolver:
| Protocol | Transport | Port | Standard |
|---|---|---|---|
| DNS over TLS (DoT) | TLS over TCP | 853 | RFC 7858, 2016 |
| DNS over HTTPS (DoH) | HTTPS | 443 | RFC 8484, 2018 |
| DNS over QUIC (DoQ) | QUIC | 853 | RFC 9250, 2022 |
DoH looks like any other HTTPS traffic, which makes it hard to block, the reason browsers adopted it first. You can try it with curl (answer shortened):
curl -s -H 'accept: application/dns-json' \
'https://cloudflare-dns.com/dns-query?name=farschidnia.de&type=A'
{"Status":0,"AD":false,"Answer":[{"name":"farschidnia.de",
"type":1,"TTL":600,"data":"92.205.105.140"}]}
"AD":false shows again that the domain is not DNSSEC-signed.
Encrypted DNS moves trust, it does not remove it. The resolver still sees every query, so choose one whose privacy policy you accept. And the domain name can still leak in the TLS handshake (the SNI field) until Encrypted Client Hello is widely used. In companies, encrypted DNS in browsers can bypass internal DNS and security filters, which is why many corporate networks configure or disable it centrally.
12. When DNS Breaks
DNS failures are dramatic because DNS sits under everything. Two famous examples:
- Facebook, 4 October 2021. A configuration change withdrew the network routes (BGP) to Facebook's own authoritative DNS servers. Resolvers worldwide could no longer find
facebook.com,instagram.comorwhatsapp.com, and the outage lasted about six hours. Internal tools depended on the same DNS, which slowed the recovery. - Dyn, 21 October 2016. The DDoS on the DNS provider Dyn (section 9) took down sites that had a single DNS provider.
Most everyday DNS problems are smaller and self-inflicted:
- A record changed, but the old TTL was one day.
- A new name was queried before it existed and is now stuck in negative caching.
- A firewall blocks TCP port 53, so large answers fail.
- A forgotten
/etc/hostsentry overrides DNS on one machine. - A Java service caches an old address in the JVM.
- Split-horizon DNS: the same name resolves differently inside and outside the company network, and nobody remembers which one the failing server uses.
A short debugging routine helps:
dig example.com # what does my resolver say?
dig @1.1.1.1 example.com # what does a public resolver say?
dig @ns1.provider.net example.com # what does the source say?
dig +trace example.com # walk the whole path
If the authoritative server is right and your resolver is wrong, it is a cache. If the authoritative server is wrong, it is the zone. If the trace breaks along the way, it is the delegation.
13. A Checklist for Your Own Domain
- Two or more name servers on different networks. Ideally, use a provider with anycast.
- Sensible TTLs: around one hour for stable records, short only before planned changes.
- AAAA records if your server has IPv6, so IPv6-only and dual-stack clients connect directly.
- A CAA record that names your certificate authority, for example
CAA 0 issue "letsencrypt.org". Other CAs must then refuse to issue certificates for your domain. - DNSSEC, if your provider manages the keys automatically.
- SPF, DKIM and DMARC TXT records if the domain sends mail, so others cannot send mail in its name.
- No unneeded wildcard records.
- Registrar account protected with two-factor authentication and the transfer lock.
- Monitoring that resolves your main names from outside, not only from your own network.
14. Conclusion
DNS turns names into addresses through a simple, layered design: a tree of delegations from the root, walked by recursive resolvers and answered mostly from caches. That design has scaled from a few hundred hosts in 1983 to the whole internet.
The things to remember:
- Every answer is a cached answer, valid for its TTL. There is no propagation, only expiry.
- DNS is on the critical path of every new connection. A cached answer costs nothing, a miss costs several round trips.
- Classic DNS trusts the first answer it gets. DNSSEC adds signatures, encrypted DNS adds privacy, and both are still far from universal.
- When everything is down, check DNS first. It is not always DNS, but it is often enough.
Run the three dig commands from section 2 against your own domain. In a minute you will see every server that has to answer before anyone can reach you.
Sources and Further Reading
- P. Mockapetris, RFC 1034: Domain Names – Concepts and Facilities, and RFC 1035: Domain Names – Implementation and Specification, 1987.
- M. Andrews, RFC 2308: Negative Caching of DNS Queries, 1998.
- J. Damas, M. Graff, P. Vixie, RFC 6891: Extension Mechanisms for DNS (EDNS(0)), 2013.
- R. Arends et al., RFC 4033–4035: DNS Security Introduction and Requirements (DNSSEC), 2005.
- Z. Hu et al., RFC 7858: DNS over TLS, 2016; P. Hoffman, P. McManus, RFC 8484: DNS Queries over HTTPS, 2018; C. Huitema et al., RFC 9250: DNS over Dedicated QUIC Connections, 2022.
- B. Schwartz, M. Bishop, E. Nygren, RFC 9460: Service Binding and Parameter Specification via the DNS (SVCB and HTTPS Records), 2023.
- P. Hallam-Baker, R. Stradling, J. Hoffman-Andrews, RFC 8659: DNS Certification Authority Authorization (CAA), 2019.
- Root server information: https://root-servers.org
- DNS Flag Day 2020: https://www.dnsflagday.net/2020/
- Facebook Engineering, "More details about the October 4 outage", 2021.




