Sub topic 3
The DNS hierarchy: root, TLD, and authoritative servers
This chapter assumes you can read a fully qualified domain name (FQDN) and know what an IP address is. It also assumes you can run commands in a terminal. Here you will see how DNS splits responsibility across three levels of servers. The next chapters cover zones and the step-by-step resolution process.
Why a hierarchy
DNS is not one big table. No single server stores every name on the internet. Instead, the namespace is a tree, and each level knows only who is responsible for the level directly below it. This is called delegation. A server at one level does not hold the answer for a name. It holds a pointer to the servers that do.
This design spreads the load and the administration. The operator of example.com can change its records without asking anyone, because that part of the tree was handed to them.
The three levels
Reading an FQDN from right to left walks down the tree. The trailing dot in www.example.com. stands for the root.
- Root. The root servers know which servers run each top-level domain (TLD), such as
com,org, orde. There are 13 root server identities, nameda.root-servers.netthroughm.root-servers.net. Each identity is served by many machines spread around the world using anycast, which means many machines share one address and the network routes you to a nearby one. - TLD. The servers for a TLD know which name servers are responsible for each domain registered under it. The
comservers do not know the address ofwww.example.com. They know which servers to ask aboutexample.com. - Authoritative. These servers hold the actual records for a domain. A server is authoritative when it gives answers from its own data instead of from a cache.
Referrals and answers
Every response from a non-final level is a referral. A referral is a reply that says "I don't have this, ask these servers." It uses NS records, which list name servers, and often adds glue records. A glue record is an A or AAAA record for a name server that sits inside the very domain it serves. Without glue you would face a loop: to find ns1.example.com you would need to resolve example.com, which needs ns1.example.com.
Only the authoritative server returns the final answer. Its response carries the aa (authoritative answer) flag.
Seeing the hierarchy with dig
The +trace option makes dig walk the tree itself, starting at a root server.
dig +trace www.example.comThe output has three stages. First you see the root servers returning NS records for com.. Next, a com server returns NS records for example.com.. Last, one of those servers returns the answer for www.example.com.. Each block is one step down the tree.
You can also ask one authoritative server directly and check for the aa flag:
dig @a.iana-servers.net example.com A +norecurse+norecurse tells the server not to search on your behalf. An authoritative server still answers for its own data.
Common errors
- Assuming the TLD holds your records. The TLD only holds NS (and glue) data for your domain. Your A, MX, and TXT records live on your authoritative servers.
- Lame delegation. The TLD refers to a server that is not configured to answer for your domain. Queries to it fail or return
REFUSED. This usually follows a change of DNS provider where the registrar still lists the old name servers. - Mismatched NS sets. The NS records at the TLD and the NS records in your zone should list the same servers. If they differ, some resolvers use one set and some the other, and the results look random.
- Missing glue. If your name servers are inside your own domain and the registrar has no glue for them, the domain does not resolve.
Check your understanding
Exercise
You run dig +trace www.example.com. Which level of server returns the NS records that name the authoritative servers for example.com, and what does it not return?
Show answer
The com TLD servers return the NS records (and any glue) for example.com. They do not return the A record for www.example.com. That final answer comes only from an authoritative server for example.com.
Exercise
A domain stopped working after you moved DNS providers. The new provider's zone is correct, but dig +trace shows the TLD referring to the old provider's servers. What is wrong, and where do you fix it?
Show answer
The delegation at the TLD still lists the old name servers. Update the name servers at the registrar, which passes the change to the registry that runs the TLD.