Sub topic 3
The DNS Hierarchy: Root, TLD, and Authoritative Servers
This chapter assumes you know what an IP address is, can run commands in a terminal, and have read the previous chapter on the parts of a domain name (labels, TLDs, subdomains, FQDNs). It covers who answers DNS questions at each level, how the levels connect, and how to see those connections yourself.
Why DNS is a hierarchy
Early networks kept all name-to-address mappings in a single shared file. That approach fails at internet scale. One file would need constant edits from millions of owners, and every machine would need a fresh copy.
DNS solves this by splitting the namespace into a tree and splitting responsibility along the same lines. No server knows every name. Each server knows its own part of the tree and knows where to send you for the parts below it. This is called delegation.
The tree is read right to left. In www.example.com., the final dot stands for the root, com is one level below the root, example is one level below com, and www is one level below example.
The three levels of servers
Each level has a different job, a different operator, and a different kind of answer.
Root servers
The root zone is the top of the tree. It does not hold addresses for websites. It holds one set of records for each TLD: the names of the servers that handle com, org, uk, and the rest.
There are 13 root server identities, named a.root-servers.net through m.root-servers.net. Each identity is not one machine. Operators use anycast, which means many physical servers around the world announce the same IP address, and your packets reach the nearest one. In total there are well over a thousand root server instances. About a dozen independent organizations operate the 13 identities.
The content of the root zone is overseen by IANA, a function run under ICANN. A separate organization acts as the root zone maintainer and distributes the file to the operators.
Every recursive resolver ships with a root hints file. This is a short list of the root server names and addresses, and it is how a resolver with an empty cache finds its first server to ask.
TLD servers
A top-level domain (TLD) is the last label of a name. TLD servers answer one kind of question: "which name servers are responsible for this second-level domain?" They hold delegations such as example.com, not individual hosts such as www.example.com.
TLDs come in several kinds:
- Generic TLDs (gTLDs), such as
com,org,net, and newer ones such asapp. - Country-code TLDs (ccTLDs), such as
uk,de, andjp. - Sponsored or restricted TLDs, such as
eduandgov, which have eligibility rules.
Each TLD is run by an organization called a registry. Verisign runs com, and Nominet runs uk. Registries do not sell domains to the public directly. Registrars do, and a later chapter covers that relationship.
Authoritative servers
Authoritative servers hold the actual records for a zone: the A, AAAA, MX, TXT, and other records you configure. When a name server is authoritative for example.com, its answer is the final word on that name.
Authoritative servers are usually run by the domain owner's DNS provider. That might be a registrar's default DNS, a cloud DNS service, a hosting company, or your own server. This is the only level where you control the data.
Delegation: how one level points to the next
A parent zone delegates a child zone by publishing NS records for it. The com zone contains NS records saying "the servers for example.com are ns1.example.com and ns2.example.com" (or whatever the owner chose at registration). The point where one zone hands off to another is called a zone cut.
A server that receives a query it cannot answer, but knows who can, replies with a referral. A referral has no answer for the name you asked about. It contains NS records in the authority section of the response, pointing one level down.
Glue records
A delegation can create a circular dependency. Suppose example.com is served by ns1.example.com. To find ns1.example.com, a resolver must first query the servers for example.com, and those are the servers it is trying to find.
The parent breaks the loop with glue records. These are A or AAAA records for the name servers, stored in the parent zone and sent in the additional section of the referral. With glue, the resolver gets ns1.example.com and its IP address in one response. Glue is needed only when the name server's name sits inside the zone it serves. A server named ns1.dnsprovider.net serving example.com needs no glue in the com zone.
Parent and child both hold NS records
The NS records in the parent zone and the NS records inside the child zone are stored separately. The parent's copy is what resolvers follow first. The child's copy is what the child servers report about themselves. When you change name servers, you must update the parent's copy, which means changing it at your registrar. Editing only the NS records in your own zone file has no effect on where the world looks.
Watching the hierarchy with dig
The dig tool can play the role of a resolver. The option +norecurse clears the recursion-desired flag, so the server only returns what it knows. These three queries repeat by hand the steps a resolver takes.
dig @a.root-servers.net www.example.com A +norecurse
dig @a.gtld-servers.net www.example.com A +norecurse
dig @a.iana-servers.net www.example.com A +norecurseThe first query goes to a root server. Its answer section is empty. The authority section lists the com name servers, and the additional section holds their addresses as glue.
The second query goes to one of those com servers. It also has no answer, but it returns a referral listing the name servers for example.com.
The third query goes to a server that is authoritative for example.com. The reply has an answer section with the A record, and the flags line includes aa (authoritative answer).
The server names in the second and third queries come from the previous response. If the delegation of example.com changes, use whatever names the referral returned.
To run the whole walk automatically, use the trace option from the spine:
dig +trace www.example.comdig +trace starts from its own root hints, queries a root server, follows each referral, and prints each response in turn. You can also ask for the delegation data directly:
dig . NS +short
dig com NS +short
dig example.com NS +shortThe first command lists the 13 root server names. The second lists the com TLD servers. The third returns the authoritative servers for example.com.
Comparing the three levels
| Level | Knows | Typical answer | Operated by |
|---|---|---|---|
| Root | Which servers run each TLD | Referral to TLD servers | Root server operators, overseen by IANA |
| TLD | Which servers run each registered domain | Referral to authoritative servers | A registry, such as Verisign for `com` |
| Authoritative | The records of a zone | The final answer, with the `aa` flag | The domain owner or their DNS provider |
Edge cases and common errors
Not every TLD is one level deep
Some registries create public suffixes below the TLD, such as co.uk or com.au. Ownership still works the same way, but the delegation you buy is example.co.uk, not example.uk. Browsers and cookie rules use the Public Suffix List to know where the registrable part of a name starts. DNS itself does not use that list.
Subdomains can be delegated too
Your own zone can delegate a child zone. If you add NS records for dev.example.com that point at other servers, those servers control everything under dev.example.com. Records you place for that name in the parent zone are ignored by resolvers that follow the delegation. A frequent mistake is adding both an NS delegation and ordinary records for the same label.
Lame delegation
A delegation is lame when the parent lists a name server that does not answer authoritatively for the zone. Typical causes are a provider that was cancelled, a zone never created on the new provider, or a typo in the name server name. Resolvers try other listed servers, so the failure may be intermittent: some lookups succeed and others time out or return SERVFAIL. Check each name server listed for the domain separately with dig @server example.com SOA +norecurse.
Mismatched NS sets
If the parent lists ns1 and ns2 but the zone itself lists ns3 and ns4, resolvers can see different sets depending on which they cached. Keep both lists identical.
Anycast hides the real server
Because many machines share one root address, dig output shows the same IP from anywhere on Earth. To see which instance answered, query the special name hostname.bind in the CHAOS class. Not all root operators support it, and the exact output varies by operator.
dig @a.root-servers.net hostname.bind CH TXT +shortCaching hides the hierarchy
In normal use, resolvers cache the TLD delegations for a long time, so root servers rarely see a query for any given TLD. This is why the root servers can carry the load of the whole internet.
Exercise
You run dig @a.gtld-servers.net www.example.com A +norecurse. The response has an empty answer section, NS records in the authority section, and A records in the additional section. What does each part mean, and which level of the hierarchy answered?
Show answer
A TLD server (for com) answered with a referral. The empty answer section means it does not hold the www.example.com record. The NS records in the authority section name the servers responsible for example.com. The A records in the additional section are glue, which give the IP addresses of those name servers so the resolver can contact them without another lookup. The next query goes to one of those authoritative servers.
Exercise
You moved your DNS to a new provider and edited the NS records inside your zone file to list the new servers. Some users still reach the old provider. Why, and what should you change?
Show answer
Resolvers follow the NS records stored in the parent zone (com, in this case), not the copy inside your own zone. The delegation is changed only at your registrar, which updates the registry. Update the name servers at the registrar, and keep the NS records in the new zone consistent with them. Old delegations also stay in resolver caches until their TTL expires.