Linux concept: DNS
DNS is the part of the internet everyone blames and almost nobody owns. When a website goes down, when mail stops arriving, when a certificate refuses to renew, somebody says "it is probably DNS" and they are right more often than they should be. The reason is not that DNS is fragile. It is that a single domain name is usually spread across three different companies, configured by four different people, and cached in a thousand places nobody controls.
1. The Basics
The Domain Name System turns names into the information a computer needs to reach a service. Most of the time that is an IP address, but DNS also carries where your mail goes, which certificate authorities may issue for you, and which servers are allowed to send on your behalf.
It is often described as the phone book of the internet. That comparison is comforting and slightly wrong, because a phone book is one document that somebody prints. DNS is a distributed database with delegated authority: no single machine holds it, no single organisation publishes it, and every part of it is answered by whoever was handed responsibility for that part.
That delegation is the whole design. The root delegates .nl to the Dutch registry. The Dutch registry delegates petermartin.nl to whichever name servers the owner nominated. Those name servers answer for everything below it. Each level knows only enough to point at the next one.
The right mental model: DNS is not a lookup table, it is a chain of referrals. Nobody has the whole answer; everybody knows who to ask next. Almost every confusing DNS problem is a broken link in that chain, or a cached copy of a link that has since changed.
1.1 The Four Roles
Four different kinds of software are involved in every lookup, and mixing them up is the single most common source of confusion. They are not interchangeable.
| Role | What it does | Example |
|---|---|---|
| Stub resolver | The tiny client inside your machine. Knows nothing, asks one server, believes the answer. | systemd-resolved on 127.0.0.53 |
| Recursive resolver | Does the actual chasing, from the root downwards, and caches what it learns. | Your ISP, 1.1.1.1, 8.8.8.8 |
| Authoritative server | Holds the real records for a zone and never caches anything. The source of truth. | chelsea.ns.cloudflare.com |
| Registry | Runs a top-level domain and publishes the delegation that points at your name servers. | SIDN for .nl, Verisign for .com |
The practical consequence: "the DNS is wrong" is never a complete sentence. A record can be correct on the authoritative server, stale in a recursive resolver, and absent from your own machine's cache, all at the same moment, and all three are behaving properly.
1.2 What One Lookup Actually Does
When your browser needs www.petermartin.nl and nothing is cached anywhere, this is the journey:
your browser
↓ "where is www.petermartin.nl?"
stub resolver (127.0.0.53)
↓
recursive resolver (your ISP, or 1.1.1.1)
↓ asks a root server: "who handles .nl?"
↓ asks the .nl registry: "who handles petermartin.nl?"
↓ asks Cloudflare: "what is www.petermartin.nl?"
↓
back up the chain, cached at every step that allows it
Three requests to three different organisations, for one name. This sounds slow, and the first lookup is. Every step after that is answered from cache until the TTL runs out, which is why the second visit to a site feels instant.
The important part is what gets cached and where. The recursive resolver caches the answer and the referrals, so the next visitor asking for a different name under .nl skips the root entirely. This is also why a change you make is invisible to some people and not others: their resolvers cached at different moments.
1.3 What This Article Covers
This article is about DNS as something you design and own: who holds which piece, how to lay out a zone, how mail authentication fits together, what to do about resilience and DNSSEC, and which decisions you will regret later.
It deliberately does not repeat the mechanics of inspecting DNS from the command line. For reading records, following a delegation, checking a cache, and choosing TTL values, see the companion article on the dig command, which covers the tooling in detail. Here the question is not "how do I see it" but "what should it be".
Back to top2. Where the Name Comes From
DNS stands for Domain Name System, and the word carrying the meaning is domain.
DNS = Domain Name System
A domain is a region of authority. It is the same sense as in "the domain of a king": a bounded area where one party decides. In DNS, owning a domain means you decide what every name inside it resolves to, and nobody above you in the tree can tell you otherwise. They can only decide whether to keep pointing at you.
Names are read right to left, from the most general to the most specific, and each dot-separated piece is called a label:
www . petermartin . nl .
| | | |
| | | └─ the root, written as an empty label
| | └─── top-level domain, run by a registry
| └─────────── the domain you registered
└─────────────────── a name inside your zone, your choice
That trailing dot is not decoration. It is the root of the tree, and a name written with it is fully qualified: it means exactly this name and nothing else. Most software lets you leave it off and adds it silently, which is why it looks unfamiliar even to people who have used DNS for years.
One more term worth pinning down, because it is used loosely everywhere. A zone is the part of the tree that one set of name servers actually answers for. A domain is what you registered; a zone is what a server serves. They are usually the same thing, and stop being the same the moment you delegate a subdomain to somebody else.
Back to top3. A Short History
DNS was not designed as a grand architecture. It was written to solve an administrative crisis: one text file that had stopped scaling.
Before DNS, every machine on the ARPANET kept a local copy of a single file called HOSTS.TXT, maintained by the Network Information Center at the Stanford Research Institute. Every new host meant editing that file, and every machine on the network downloading it again. As the network grew, the file grew, the downloads grew, and the delay between "a host exists" and "everyone knows about it" grew with them.
In November 1983 Paul Mockapetris published the replacement as two documents: RFC 882, "Domain Names Concepts and Facilities", which described the idea, and RFC 883, "Domain Names Implementation and Specification", which defined how it worked on the wire. The insight was to stop distributing a file and start distributing authority.
| Year | Milestone |
|---|---|
| Until 1983 | One HOSTS.TXT file, edited by hand and copied to every machine |
| 1983 | Paul Mockapetris publishes RFC 882 and RFC 883, replacing the file with a delegated tree |
| 1987 | RFC 1034 and RFC 1035 supersede them, and still define DNS today |
| 1998 | ICANN is formed to coordinate names and numbers |
| 2010 | The root zone is signed with DNSSEC, on 15 July, giving the chain of trust a starting point |
| 2016 | RFC 7858 specifies DNS over TLS, and a large attack on one DNS provider takes down much of the web |
| 2018 | RFC 8484 specifies DNS over HTTPS, moving DNS into the browser |
| Today | Around two thousand root server instances, twelve operators, one protocol that still looks like 1987 |
Two things are worth taking from that table. The core specification is from 1987 and has never been replaced, only extended. And every extension since has been about the two things the original did not consider: proving an answer is genuine (DNSSEC), and keeping the question private (DoT and DoH). The original design assumed a small, trusting network, because in 1983 that is what it was.
Back to top4. Who Owns What
This section exists because it is the single most common misunderstanding in practice, and it costs people days. A domain that feels like one thing you bought is really three separate arrangements with three different companies, and knowing which one to log into is most of the battle.
4.1 Registry, Registrar, Registrant
Three parties, similar names, completely different jobs:
| Party | Who they are | What they control |
|---|---|---|
| Registry | The operator of a whole top-level domain. One per TLD. | The authoritative list of which name servers serve your domain |
| Registrar | The company you buy from, accredited to write into the registry. | Your registration, renewals, and the name servers submitted on your behalf |
| Registrant | You. | Everything inside the zone, once the delegation points at your servers |
You never talk to the registry. You talk to a registrar, and the registrar talks to the registry on your behalf. That indirection is why a name server change made at your registrar can take a little while to appear at the registry, and why the registry's copy is the one the world follows.
4.2 The Three-Way Split, on a Real Domain
Now the part that surprises people. The company you bought the domain from, the company answering DNS queries for it, and the company running the actual website are frequently three unrelated businesses. Here is petermartin.nl, taken apart:
$ whois petermartin.nl | grep -A3 '^Registrar'
Registrar:
Registrar.eu
Hofplein 20
3032AC Rotterdam
$ dig +short petermartin.nl NS
finley.ns.cloudflare.com.
chelsea.ns.cloudflare.com.
$ dig +short petermartin.nl
23.88.98.40
$ whois 23.88.98.40 | grep -iE '^(netname|org-name|country):'
netname: CLOUD-NBG1
org-name: Hetzner Online GmbH
country: DE
Three companies, three countries' worth of paperwork, one domain name:
| Layer | Who | What breaks if it is wrong |
|---|---|---|
| Registration | Registrar.eu, Rotterdam | The domain expires, or the delegation points at the wrong name servers |
| DNS hosting | Cloudflare | Records are wrong or missing; the name resolves to nothing |
| Web hosting | Hetzner, Germany | The name resolves fine and the site still does not load |
None of these is unusual. It is a perfectly normal, well-run setup. But it explains why "my hosting company should fix my DNS" so often goes nowhere: the hosting company may have nothing to do with it.
4.3 Where Does This Change Have to Be Made?
Keep this table. It answers the question that actually blocks people.
| You want to | Log in to |
|---|---|
| Point the site at a new server | The DNS host (edit the A record) |
| Move to a different DNS provider | The registrar (change the name servers) |
| Change where mail is delivered | The DNS host (edit the MX records) |
| Renew the domain, or stop it expiring | The registrar |
| Turn on DNSSEC | Both: the DNS host signs, the registrar publishes the DS record |
| Fix a site that loads slowly or throws a certificate error | Probably nobody in this table. It is the web host |
The second and fifth rows are the ones people get wrong. Changing name servers is a registrar action, not a DNS action, and no amount of editing records at either provider will do it. Turning on DNSSEC needs both ends to agree, which is why it is the one change most likely to be left half-finished.
Back to top5. Designing a Zone
Once the delegation points at your name servers, everything inside the zone is your decision. Most zones are small, and most of the trouble in them comes from four or five choices that were made without much thought and are painful to reverse.
5.1 The Apex, and Why CNAME Does Not Work There
The apex (or "root" of your zone) is the bare domain, example.com with nothing in front. It is special, and it catches everybody exactly once.
You cannot put a CNAME on the apex. The standards forbid a CNAME from sitting alongside any other record, and the apex always carries SOA and NS records, because that is what makes it a zone. So a CNAME there is not merely discouraged; it is unrepresentable.
This collides directly with modern hosting, where providers hand you a name rather than an address, precisely so they can change the address behind it. The answers, in order of preference:
| Option | How it works | Trade-off |
|---|---|---|
ALIAS / ANAME / CNAME flattening |
The DNS provider resolves the target for you and publishes the result as a plain A record |
Not a standard, so it is a provider feature. Works well; ties you to that provider |
| Redirect the apex | Point the apex at a small server that sends visitors to www |
Clean and portable, but needs something to run the redirect |
A plain A record |
Hard-code the address | Simple, until the provider changes the address without telling you |
If your provider offers flattening, use it. If it does not, that is a genuine reason to consider one that does.
5.2 Pick www or Not, Then Commit
Both work. What causes problems is serving both as equals, because then every page exists at two addresses, and search engines, cookies, and certificates all have to be told they are the same thing.
Choose one as canonical, publish both in DNS, and redirect one to the other at the web server with a permanent redirect. The DNS side is unremarkable:
example.com. 300 IN A 203.0.113.10
www.example.com. 300 IN CNAME example.com.
The CNAME is fine on www, because www is an ordinary name inside the zone, not the apex. Only the apex is restricted.
5.3 Subdomains: Records or Delegation?
There are two quite different ways to have a subdomain, and choosing the wrong one creates work later.
- Records in your own zone.
shop.example.comis just another name you manage alongside everything else. This is what you want almost always. - Delegation. You publish
NSrecords forshop.example.compointing at somebody else's name servers, and hand over that whole branch. From then on you cannot see or fix anything inside it.
Delegate only when a different team or platform genuinely needs to run its own records at speed, which in practice means large organisations and some cloud platforms. For a single site, delegation adds a second place for things to break and a second chain of trust to keep intact.
5.4 Wildcards Answer for Names You Never Created
A wildcard record matches anything that does not have its own entry:
*.example.com. 300 IN A 203.0.113.10
It looks convenient and it quietly changes the meaning of your zone. Every typo now resolves. Every subdomain an attacker invents resolves. Monitoring that checks "does this name exist" always says yes. And a wildcard plus a permissive web server is the classic setup for subdomain takeover, where somebody serves their content on a name that appears to be yours.
Use a wildcard when you genuinely serve unlimited names, such as customer subdomains on a platform. Otherwise list the names you actually have. The typing is not the expensive part of running a zone.
5.5 Split Horizon: The Same Name, Two Answers
Some organisations answer differently for the same name depending on who is asking: a private address on the office network, a public one from outside. This is split horizon, and it is a legitimate design.
It is also a trap for whoever debugs it later, because two people running the same command in good faith get different answers and both conclude the other is confused. If you run split horizon, document it where the person on call will find it, and expect every external DNS checking tool to disagree with what you see at your desk.
5.6 Choosing TTLs
Every record carries a TTL, the number of seconds a resolver may cache it, and the value is a real design decision rather than a default to accept. It decides how fast you can move, and how long you keep working when your name servers do not.
The short version: 300 seconds for addresses, a day for NS records, an hour for mail and text records, and lower everything a day before a planned migration. The reasoning, with measurements from well-run domains and the trade-off in both directions, is in the dig article, which also shows how to read what a zone actually publishes rather than what a cache is telling you.
6. What DNS Is Used For Besides Addresses
Finding a web server is the job DNS is famous for, and it is no longer the job it does most. Over the years DNS became the place the internet keeps its policy statements: who may send mail as you, who may issue certificates for you, and whether an answer can be trusted at all. These are the records that fail quietly and cost the most.
6.1 Mail Authentication Is One System, Not Three Records
Nothing in DNS confuses people like SPF, DKIM and DMARC, mostly because they are usually explained one at a time. They are three parts of a single question: should this message be believed?
| Record | Question it answers | Lives at |
|---|---|---|
MX |
Where does mail to this domain go? | The domain itself |
SPF (a TXT record) |
Which servers may send as this domain? | The domain itself |
DKIM (a TXT record) |
Is this message signed by a key the domain published? | selector._domainkey |
DMARC (a TXT record) |
What should a receiver do when SPF and DKIM disagree with the From address? | _dmarc |
PTR |
Does the sending IP admit to being this name? | The reverse zone, at whoever owns the IP |
Read down that table and the design appears. MX is about receiving; the rest are about sending. SPF authorises servers, DKIM authorises messages, and DMARC is the instruction that turns those checks into a decision and asks for reports.
The ordering matters when you deploy them. Publish SPF and DKIM first and let them run. Then add DMARC at p=none, which changes nothing but asks receivers to send you reports. Read those reports for a few weeks, find the legitimate senders you had forgotten (the invoicing system, the newsletter platform, the contact form on the old site), and only then tighten to p=quarantine and p=reject.
Going straight to p=reject is the classic self-inflicted outage: it works perfectly for the mail you remembered and silently destroys the mail you did not.
The PTR record is the odd one out and the one people cannot fix themselves. It lives in the reverse zone for the IP address, which belongs to whoever owns the address space, so it is set by your hosting provider and not by you. If you send mail from your own server, a missing or generic PTR is a common reason for delivery problems that look inexplicable from your side.
6.2 DNS as Proof of Ownership
A whole category of services asks you to create a DNS record for a reason that has nothing to do with resolving names: to prove you control the domain. Only the owner can publish a record in the zone, so publishing one on request is a workable proof.
_acme-challenge.example.com. 300 IN TXT "3aQ7v...token..."
example.com. 300 IN TXT "google-site-verification=..."
_dmarc.example.com. 300 IN TXT "v=DMARC1; p=none; rua=mailto:..."
The first is the DNS-01 challenge used by Let's Encrypt and other ACME providers, and it is worth understanding because it does something the usual HTTP challenge cannot: it issues certificates for a server that is not reachable from the internet, and it is the only way to get a wildcard certificate. The cost is that your certificate renewal now depends on your DNS provider having an API, and on that API still working at three in the morning eighty days from now.
Verification records are also where zones accumulate junk. Every service you ever trialled left a TXT record behind. They are harmless individually and collectively they make the zone unreadable, so it is worth a yearly pass to delete the ones whose services you no longer use.
6.3 CAA: Who May Issue Certificates For You
A CAA record lists the certificate authorities allowed to issue for your domain. Authorities are required to check it before issuing, which makes it a genuine control rather than a suggestion:
example.com. 3600 IN CAA 0 issue "letsencrypt.org"
example.com. 3600 IN CAA 0 issuewild "letsencrypt.org"
It is a small, high-value record: it limits the damage if someone tricks a different authority into issuing for your name. It is also a reliable cause of certificate renewals failing years later, when a company changes provider and nobody remembers a record set in a previous job. If a renewal fails for no visible reason, check CAA early.
6.4 DNSSEC: Should You Sign?
DNSSEC signs the records in a zone so a validating resolver can prove an answer came from you and was not modified on the way. The chain runs from the root, which was signed in 2010, down through the registry to your zone.
The honest summary of the trade-off:
- What you gain. Answers for your domain cannot be forged in transit or poisoned into a resolver's cache. It is also a prerequisite for anything that puts trust in DNS records, such as publishing certificate fingerprints.
- What it costs. Signatures expire. If signing breaks and nobody notices, your domain does not degrade, it vanishes for every validating resolver at once, which today is most of them. And the failure mode looks like a working domain from the authoritative server, so it is confusing to diagnose.
- What decides it. Whether your DNS provider handles the whole lifecycle, including key rollovers, and whether pushing the
DSrecord to your registrar is a button rather than a support ticket.
With a provider that manages it end to end, turn it on. If signing would be a manual job you perform once and never revisit, the risk is real and you should think harder. A half-finished DNSSEC deployment, where the zone is signed but the registrar's DS record was never published, is the common middle state: it achieves nothing and nobody notices, because everything keeps working.
6.5 Encrypted DNS, and What It Changes For You
Classic DNS travels in plain text, so anyone on the path can read what you look up and change the answer. Two standards fixed this: DNS over TLS (RFC 7858, May 2016) on port 853, and DNS over HTTPS (RFC 8484, October 2018) on port 443.
Both encrypt the conversation between a client and its resolver. Neither encrypts anything about your authoritative servers, and neither changes a single record you publish, so as a domain owner there is nothing to configure.
What it changes is debugging. A browser with DoH enabled may bypass the resolver the operating system is configured to use, so the machine and the browser can genuinely disagree about a name. When a site loads in one browser and not another on the same laptop, encrypted DNS in the browser's own settings is a real suspect, and it is why the mail and web checks people run from the command line sometimes do not reflect what the browser did.
Back to top7. DNS on a Linux Machine
Everything so far has been about the domain you publish. This section is about the machine in front of you, because the client side has its own rules and they are the reason two people can run the same lookup and disagree.
7.1 Your resolv.conf Is Probably a Symlink
The traditional place a Linux machine keeps its resolver settings is /etc/resolv.conf. Generations of documentation tell you to edit it. On a modern system that advice is usually wrong, and here is the proof:
$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Apr 24 2024 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
$ cat /etc/resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search .
The file is a symlink into a directory that is regenerated at boot. Anything you type into it is lost the next time the machine restarts, or sooner. Several pieces of software may be generating it: systemd-resolved, NetworkManager, a DHCP client, resolvconf, a VPN client, or a container runtime.
On most networks the DNS servers in that file did not come from a person at all: they arrived in a DHCP lease, along with the address and the gateway. The companion article on DHCP covers where those settings come from and why editing them here does not last.
That 127.0.0.53 is not a DNS server on the internet. It is the local stub, and the real upstream servers sit behind it, per network interface. The honest way to see them is to ask the thing that owns them:
$ resolvectl status | grep -A2 'Current DNS Server'
Current DNS Server: 192.168.1.1
DNS Servers: 192.168.1.1
$ resolvectl query petermartin.nl
petermartin.nl: 2a01:4f8:c0c:6848::1 -- link: wlp0s20f3
23.88.98.40 -- link: wlp0s20f3
-- Information acquired via protocol DNS in 5.2ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
The last line is worth reading twice. It reports whether the answer was DNSSEC validated and whether it travelled encrypted, which are two questions people usually guess at. Here both are "no", which is the normal state on a laptop talking to a home router.
To change the settings, change them where they are generated: the connection profile in NetworkManager, the DHCP server, or /etc/systemd/resolved.conf. Editing the symlink target is a fix that survives until Tuesday.
7.2 The Order Linux Really Resolves In
DNS is not the only way a Linux machine turns a name into an address, and it is not necessarily the first. The order lives in /etc/nsswitch.conf:
$ grep '^hosts:' /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns mymachines
Read left to right, that machine checks /etc/hosts first, then multicast DNS for .local names, and only then real DNS. The bracketed [NOTFOUND=return] means that if mDNS gives a definitive "no", the search stops there instead of falling through.
This single line explains a whole category of confusion. A name in /etc/hosts resolves for your browser and your scripts while DNS knows nothing about it. A .local name may never reach DNS at all. And a command-line DNS tool asks a name server directly, skipping this list entirely, so it can honestly disagree with every application on the machine.
The rule that follows is simple. To ask "what does DNS say", use a DNS tool. To ask "what does this machine actually do", use getent, which walks the list above exactly as an application would:
$ getent hosts petermartin.nl
The companion article on the dig command covers this boundary in more detail, including why a name can work everywhere and still appear not to exist.
7.3 Containers Have Their Own DNS, and It Depends on the Network
A container does not inherit your machine's resolver settings, and the difference bites during exactly the debugging session where you can least afford a surprise. What it gets depends on which Docker network it joined, and the two cases behave completely differently.
On the default bridge, the container is handed the host's upstream server and nothing else:
$ docker run --rm alpine cat /etc/resolv.conf
nameserver 192.168.1.1
search .
$ docker run -d --name db2 alpine sleep 60
$ docker run --rm alpine getent hosts db2
# nothing: names do not resolve here
On a user-defined network, Docker inserts its own embedded resolver and container names start working:
$ docker network create dnstest
$ docker run --rm --network dnstest alpine cat /etc/resolv.conf
nameserver 127.0.0.11
search .
options edns0 trust-ad ndots:0
$ docker run -d --network dnstest --name db alpine sleep 60
$ docker run --rm --network dnstest alpine getent hosts db
172.19.0.2 db db
That address, 127.0.0.11, is Docker's built-in DNS server, and it is what resolves one container name to another. This is why service names work in a Docker Compose stack without anyone configuring DNS: Compose creates a user-defined network for the project automatically.
Two practical consequences. First, when a containerised application cannot reach its database, test resolution inside the container, not on the host, because they are answering from different resolvers. Second, if you are debugging a stack where names do not resolve, check which network the containers are actually on before you look at anything else.
$ docker exec -it mycontainer cat /etc/resolv.conf
$ docker exec -it mycontainer getent hosts database
The same idea scales up. Kubernetes runs a cluster DNS service, usually CoreDNS, and gives every service a name such as database.default.svc.cluster.local so applications can find each other without hard-coded addresses. DNS stopped being only an internet directory some time ago; inside modern platforms it is the service-discovery layer.
7.4 Do Not Become an Open Resolver
You can run your own recursive resolver on Linux, and there are good reasons to: local caching, your own DNSSEC validation, independence from a third party, and logs you control. unbound is the usual choice, and BIND can do it too.
There is one way to get this badly wrong, and it is worth stating plainly. A recursive resolver that answers anyone on the internet is an open resolver, and it will be found and abused within days.
The abuse is amplification. DNS traditionally runs over UDP, which does not verify who sent a packet, so an attacker sends small queries with the victim's address forged as the source. Your server dutifully sends much larger answers to the victim. A modest request becomes a flood, the attacker spends almost nothing, and the traffic arrives from your address rather than theirs.
Preventing it is not complicated:
- Restrict recursion to clients you trust, meaning your own networks. This one setting removes the entire problem.
- Keep the two roles separate. A server that publishes your zones to the world is authoritative and needs no recursion at all. A server that resolves for your staff is recursive and should not be reachable from outside. Combining them on one public address is how this usually happens by accident.
- Turn on response rate limiting on anything that does face the internet.
The general principle is worth carrying beyond DNS: before exposing any DNS server, know whether it is meant to be authoritative, recursive, or both, because the correct configuration is different in each case and the failure mode is that somebody else uses your bandwidth to attack a stranger.
Back to top8. Something Most Users Do Not Know
8.1 The 13 Root Servers Are Not 13 Machines
Everyone learns that DNS has thirteen root servers, named a through m. That is true, and it leads to two wrong conclusions: that thirteen computers hold up the internet, and that they are mostly in the United States. Both are decades out of date, and you can disprove them from your own terminal.
Every root server answers a special query that reveals which physical instance you actually reached. Ask all thirteen:
$ for L in a b c d e f g h i j k l m; do
printf '%-22s ' "$L.root-servers.net"
dig @$L.root-servers.net hostname.bind CH TXT +short
done
Run from a machine in the Netherlands, that gives:
| Server | Instance reached | Where | Time |
|---|---|---|---|
a.root-servers.net |
nnn1-ams5 |
Amsterdam | 5 ms |
b.root-servers.net |
b3-fra |
Frankfurt | 14 ms |
c.root-servers.net |
fra1a.c.root-servers.org |
Frankfurt | 11 ms |
d.root-servers.net |
amnl3.droot.maxgigapop.net |
Amsterdam | 4 ms |
e.root-servers.net |
p01.ams.eroot |
Amsterdam | 4 ms |
f.root-servers.net |
AMS.cf.f.root-servers.org |
Amsterdam | 5 ms |
i.root-servers.net |
s1.zrh |
Zurich | 16 ms |
k.root-servers.net |
ns1.ro-buh.k.ripe.net |
Bucharest | 35 ms |
m.root-servers.net |
M-CDG-4 |
Paris | 11 ms |
Not one of them is in the United States. Every single root server identity answered from a European instance, most within 15 milliseconds. The thirteen names are not thirteen machines; they are thirteen addresses, and each address is announced from many locations at once using anycast. The network routes you to the nearest copy without you or your resolver knowing it happened.
At the time of writing the root server system is around two thousand instances run by twelve organisations. The number thirteen is a limit from 1987 on how many name servers fit in a single UDP packet, not a count of computers.
8.2 Anycast Is Also the Answer for Your Own Domain
The same trick is what any competent DNS provider sells you, and it is the main reason to use one rather than running bind on a VPS. Your two NS records look like two servers and are really two addresses announced from dozens of sites, so a visitor in Sydney and a visitor in Rotterdam both get a nearby answer, and losing a data centre changes nothing.
That covers hardware and network failure. It does not cover the provider itself failing, which is a real event: in October 2016 a very large attack against one DNS provider made a long list of well-known sites unreachable, not because those sites were down, but because nobody could look them up.
The defence is secondary DNS: the same zone served by two independent providers, published as two sets of NS records, so resolvers simply use whichever answers. It is not exotic, but it is more work than most domains need. A reasonable rule:
- One good anycast provider is right for almost every site. The failure you should actually plan for is your own mistake, not your provider's outage.
- Two providers when the domain earns money continuously, or when being unreachable for an hour is a serious event. Budget for the complexity: two places to change every record, and DNSSEC across two providers is genuinely hard.
8.3 You Do Not Own Your Domain
You rent it, in fixed terms, and the lease is the single point of failure most people never think about. Everything else in this article assumes the delegation still exists.
What actually goes wrong is unglamorous: the card on file expires, the renewal notice goes to a colleague who left, the domain was registered in a personal account belonging to a freelancer three agencies ago. The recovery, once a domain has lapsed and been picked up, ranges from expensive to impossible.
Three habits remove most of that risk:
- Registrar lock switched on, so a transfer cannot be initiated quietly.
- Auto-renew on, with a payment method that outlives individual employees, and the registrant email pointed at a role address rather than a person.
- Expiry monitoring that is not the registrar's own email. If the account is wrong, the reminders go to the wrong place, which is precisely the case you are trying to catch.
8.4 DNS Was Load Balancing Before Load Balancers
Publish several A records for one name and clients spread themselves across them. This is round robin, it is older than every load balancer product on the market, and it costs nothing:
example.com. 300 IN A 203.0.113.10
example.com. 300 IN A 203.0.113.11
It is also weak in a specific way worth knowing: DNS has no idea whether a server is alive. Take one of those machines down and DNS keeps handing out its address to a share of your visitors until you edit the zone, and then keeps doing it for the length of the TTL. It distributes load; it does not provide failover.
Failover needs something that checks. That is either a DNS provider offering health-checked records, which edits the zone for you when a target stops responding, or a real load balancer with one address in DNS and the health checking behind it. The second is almost always the better answer, because it reacts in seconds instead of TTLs.
8.5 Knowing Where DNS Stops
Part of expertise is knowing which layer a problem belongs to. DNS answers exactly one question: what does this name map to? Everything a visitor experiences after that belongs to something else.
| Symptom | Is it DNS? | Where to look |
|---|---|---|
| Site unreachable for some people, fine for others | Often yes | Caching or a delegation mismatch |
| Site loads but shows the old server | Yes | A cached record; wait out the TTL |
| Certificate warning in the browser | No | The web server's certificate, unless CAA blocked issuance |
| Site slow to load | Almost never | The application, the database, the network path |
| Mail rejected as spam | Partly | SPF, DKIM, DMARC and PTR live in DNS; reputation does not |
| "Server not found" everywhere, suddenly | Yes | Expired domain, broken DNSSEC, or a delegation that now points nowhere |
The fourth row is the one worth internalising. DNS is consulted once and then cached; it is almost never the reason a working site feels slow. When a page takes four seconds to load, the name was resolved in the first few milliseconds and everything after that was somebody else's problem.
Back to top9. Best Practices
- Know your three suppliers before you need them. Write down who the registrar, the DNS host and the web host are, and who has the login for each. The middle of an outage is the wrong time to discover the domain sits in a former colleague's personal account.
- Protect the registration first. Registrar lock on, auto-renew on, a payment method that outlives employees, and a role address as the registrant contact. Everything else in DNS assumes the domain still exists.
- Monitor expiry somewhere other than the registrar's email. If the account details are wrong, the reminders are going to the wrong place too.
- Set TTLs deliberately, and lower them a day before a planned move. 300 for addresses, a day for
NS, an hour for mail and text records. - Keep the apex on a flattened
ALIASor a plainArecord, never aCNAME, and pick eitherwwwor the bare domain as canonical rather than serving both as equals. - List the subdomains you have instead of reaching for a wildcard. A wildcard answers for names you never created, including the ones somebody else invents.
- Deploy mail authentication in order. SPF and DKIM first, then DMARC at
p=none, read the reports for a few weeks, and only then tighten. Going straight top=rejectsilently destroys the mail you forgot about. - Publish a
CAArecord naming the authority you actually use. It is two minutes of work and it limits what a mis-issued certificate can do. - Turn on DNSSEC if your provider manages the whole lifecycle, including key rollovers and pushing the
DSrecord to the registrar. If it would be a manual job you do once and never revisit, think harder. - Prefer one good anycast provider over two mediocre ones. Add secondary DNS when an hour of being unreachable is genuinely expensive, not because it sounds more professional.
- Do not use round robin as failover. DNS does not know whether a server is alive. Use health-checked records or a load balancer.
- Clean the zone once a year. Delete the verification
TXTrecords for services you stopped using and theArecords for servers that no longer exist. Old records are how subdomain takeovers start. - Do not edit
/etc/resolv.conf. On most systems it is a generated symlink. Change the setting where it is produced, and useresolvectl statusto see what your machine is really using. - Test container DNS inside the container. A container answers from a different resolver than the host, and container names only resolve on a user-defined network, not on the default bridge.
- Never expose a recursive resolver to the internet. Restrict recursion to your own networks, and keep authoritative and recursive roles on separate servers. An open resolver becomes somebody else's attack tool.
- Check changes from outside your own network. Your resolver, your router and your browser all cache, and all three can show you something the rest of the world is not seeing.
10. Common Mistakes
10.1 Myth versus Reality
| Myth | Reality |
|---|---|
| "DNS propagation takes 24 to 48 hours." | Nothing propagates. Each cache holds its copy until the TTL you published runs out. A 300 second TTL means five minutes. |
| "My hosting company controls my DNS." | Often it does not. The registrar, the DNS host and the web host are frequently three different companies. |
| "I changed the name servers at my DNS provider." | Name servers are changed at the registrar. The world follows the delegation in the parent zone, not the records in yours. |
| "There are 13 root servers." | There are 13 addresses, announced by anycast from around two thousand instances run by twelve organisations. |
"Two A records give me failover." |
They give you load distribution. DNS never checks whether a server is alive, so half your visitors keep reaching the dead one. |
| "I own my domain." | You rent it. Miss a renewal and the delegation disappears along with your mail. |
| "DNSSEC makes my site more secure." | It proves answers are genuine. It does nothing for the web server, the application or the certificate, and a broken signature takes the domain off the internet. |
| "The site is slow, it must be DNS." | DNS is consulted once and then cached. A slow page is almost always the application or the network path. |
| "A wildcard record is a convenient catch-all." | It answers for every typo and every name an attacker invents, and it hides the fact that a subdomain was never configured. |
10.2 Other Traps to Avoid
- Editing records at the old provider after moving. Once the
NSrecords point elsewhere, the old zone is ignored. People spend hours changing records that nothing reads any more. - Changing name servers and records on the same day. Move the zone first, verify both providers answer identically, and only then repoint the delegation. Otherwise a failed cutover has no clean state to return to.
- Letting the two
NSlists drift apart. The registrar's list and the list inside your zone should match. Resolvers follow the registrar's, so a mismatch is invisible where you are looking. - Signing with DNSSEC and never publishing the
DSrecord. Everything keeps working and you have gained nothing, which is why this half-finished state can persist for years. - Setting
p=rejectin DMARC on day one. Start atp=noneand read the reports, or find out which systems send as you by watching their mail disappear. - Leaving an
Arecord pointing at a server you released. When somebody else is allocated that address, your subdomain is serving their content. - Assuming the TTL you set is the TTL in use. A resolver was handed the previous value and keeps it for the full term. Your new short TTL only applies after the old one expires.
- Believing your own browser. Browser DNS caches, operating system caches and DoH settings all sit between you and reality. Check from another network before you conclude anything.
- Registering the domain in a personal account. Freelancers move on, agencies get replaced, and the domain outlives both. It belongs in an account the organisation controls.
11. Summary
DNS looks like a lookup table and behaves like an organisation chart. Almost everything that confuses people about it comes from that gap.
- DNS is a distributed database with delegated authority. The root delegates to registries, registries delegate to your name servers, and each level knows only who to ask next.
- Four kinds of software are involved and they are not interchangeable: the stub resolver on your machine, the recursive resolver that does the chasing and caches, the authoritative server that holds the truth, and the registry that publishes the delegation.
- A domain is three arrangements with three companies: the registrar you rent it from, the DNS host that answers queries, and the web host that runs the site. Knowing which one to log into is most of the work.
- Name server changes happen at the registrar. Record changes happen at the DNS host. Confusing the two costs a day.
- DNS replaced a single
HOSTS.TXTfile in 1983, and the specification everything still runs on is RFC 1034 and RFC 1035 from 1987. Every addition since has been about proving answers are genuine or keeping questions private. - The apex cannot hold a
CNAME. UseALIASor flattening if your provider offers it, or a plainArecord if it does not. - Pick
wwwor the bare domain as canonical and redirect the other. Serving both as equals creates work at every layer above DNS. - Wildcards answer for names you never created. List what you have instead.
- Mail authentication is one system:
MXfor receiving, SPF for authorised servers, DKIM for signed messages, DMARC for the decision, andPTRat your hosting provider. Deploy in that order and start DMARC atp=none. - DNS is also where the internet keeps proof of ownership: ACME
DNS-01challenges, service verification records, andCAAto name the authorities allowed to issue for you. - DNSSEC proves answers are genuine and fails hard when it breaks. Turn it on when your provider manages the whole lifecycle, including the
DSrecord at the registrar. - The 13 root servers are 13 addresses, not 13 machines: around two thousand anycast instances, twelve operators. Anycast is also what a good DNS provider sells you.
- Round robin distributes load but is not failover, because DNS never checks whether a server is alive.
- You rent your domain. Registrar lock, auto-renew, a role email, and expiry monitoring that does not depend on the registrar's own reminders.
- On a Linux machine,
/etc/resolv.confis generated and/etc/nsswitch.confdecides the real order:filesbeforedns, sogetentand a DNS tool can honestly disagree. - Containers resolve through their own server. On a user-defined Docker network that is
127.0.0.11and container names work; on the default bridge they do not. - A recursive resolver open to the internet gets abused for amplification. Restrict recursion, and keep authoritative and recursive roles apart.
- For reading records, tracing a delegation, comparing a cache with the source and choosing TTL values, the companion article on the dig command covers the tooling.
This is the checklist worth keeping when you take on a domain you did not set up:
WHO HOLDS IT
registrar who it is renewed with, and who has that login
DNS host which name servers the registrar publishes
web host who owns the IP the A record points at
IS IT SAFE
registrar lock on
auto-renew on, with a payment method nobody personally owns
registrant email a role address, not an individual
expiry alert somewhere other than the registrar's own email
IS IT SANE
apex A or ALIAS, never CNAME
www canonical one way, redirected the other
wildcards none, unless you genuinely serve unlimited names
stale records A records for dead servers, TXT for dead services
ON THIS MACHINE
resolvectl status which upstream servers are really in use
/etc/nsswitch.conf the order: files, mdns, dns
getent hosts NAME what an application sees, not what DNS says
IS IT TRUSTED
SPF, DKIM published and passing
DMARC at least p=none, with reports going somewhere read
CAA names the authority you actually use
DNSSEC signed AND the DS record published at the registrar
A domain that resolves the same way everywhere, delivers its mail, renews its certificates and survives its own renewal date is not luck: it is a handful of decisions made deliberately and written down. Most of them cost nothing at the time and are expensive to retrofit.
If you have inherited a domain nobody documented, or you are moving one between providers and want the delegation, the zone and the mail records checked before the cutover rather than during it, that is worth an hour of somebody's attention before it becomes an outage.
Back to top

Peter is a Joomla specialist and a Linux admin for fast, secure and scalable websites.












