Sub topic 3
Zones and Delegation
This chapter assumes you know the domain name hierarchy from the previous chapter (labels, FQDNs, the root and TLDs). It also assumes you can read basic dig output. Here you will learn how that hierarchy is split into zones and how authority is handed down from one zone to the next. You will also learn which mistakes break delegation in practice.
Domains and zones are not the same thing
A domain is a subtree of the name hierarchy. example.com and everything under it, such as www.example.com and a.b.example.com, form one domain.
A zone is a contiguous piece of that tree that one administrator manages as a single unit. A zone is stored as a set of records, usually in a zone file or a database. The servers that hold the zone and answer for it are its authoritative servers.
Every zone is part of a domain, but a domain can be split across several zones. If example.com hands the eng.example.com subtree to another team, you get two zones:
- The
example.comzone holds every name underexample.comexcept the subtree that was handed off. - The
eng.example.comzone holdseng.example.comand everything below it.
The point where one zone ends and another begins is called a zone cut. The zone above the cut is the parent zone. The zone below it is the child zone.
Why zones exist
Zones make delegation possible. A zone owner can give responsibility for a subtree to someone else without asking anyone else's permission. Three practical benefits follow:
- Administrative independence. The
engteam edits its own records and does not need access to the parent zone. - Scalability. No single server stores the whole namespace. The root zone is small, and each TLD zone only lists the names registered directly under it.
- Fault isolation. If the
eng.example.comservers fail, only that subtree is affected.
You do not have to delegate. Many organizations keep every name in one zone, which is simpler. Create a child zone only when someone else needs to manage the subtree, or when the zone has grown too large to manage comfortably.
How delegation is written down
Delegation lives in the parent zone as NS records. These records say "for names at or below this point, ask these servers." In the example.com zone, delegating eng looks like this:
$ORIGIN example.com.
$TTL 3600
eng IN NS ns1.eng.example.com.
IN NS ns2.eng.example.com.
ns1.eng IN A 192.0.2.101
ns2.eng IN A 192.0.2.102The child zone, eng.example.com, then has its own SOA record and its own NS records at its apex (the top name of the zone). The parent's NS records and the child's NS records should name the same servers. They are stored in two different places, so they can drift apart. That is a common source of problems, described below.
The parent is not authoritative for the NS records at a zone cut. It only holds a pointer. The child is authoritative for its own apex NS set.
Glue records
The delegation above has a problem. The name servers for eng.example.com are named ns1.eng.example.com and ns2.eng.example.com. To find their addresses, a resolver would need to look up names inside eng.example.com. To do that, it needs to ask those same servers. This is a circular dependency.
Glue records break the loop. Glue is an A or AAAA record for a name server, stored in the parent zone and returned alongside the referral. The two ns*.eng address records in the example above are glue. A resolver receives the NS names and their addresses in one response, so it can contact the child servers directly.
Glue is only required when the name server's name is inside the zone it serves. Look at two cases:
| Delegation | Name server name | Glue needed? |
|---|---|---|
| `eng.example.com` served by `ns1.eng.example.com` | Inside the delegated zone | Yes |
| `eng.example.com` served by `ns1.dnsprovider.net` | Outside the delegated zone | No |
For the second case, the resolver looks up ns1.dnsprovider.net separately, using the net zone. No loop exists.
For a domain you register, such as example.com, glue is entered at the registrar. The registrar passes it to the registry, which publishes it in the TLD zone. That is why registrars ask for name server IP addresses when you use names like ns1.example.com.
Seeing a delegation with dig
A referral is a response that points the resolver to the next set of servers. You can see one by querying a parent server directly and turning off recursion with +norecurse. First find a server for com, then ask it about example.com:
dig +short NS com.
dig @a.gtld-servers.net example.com NS +norecurseThe answer section of the second response is empty. The authority section lists the NS records for example.com, and the additional section carries any glue. The aa flag (authoritative answer) is absent because the com server is not authoritative for example.com. It is only pointing you onward.
You can also let dig walk the whole chain from the root:
dig +trace www.example.comEach block of output is one referral, from the root to com to the example.com servers, and the last block is the final answer.
Compare the NS set at the parent and the child to check consistency:
dig @a.gtld-servers.net example.com NS +norecurse +noall +authority
dig @ns1.example.com example.com NS +noall +answerThe first command asks the parent and reads the authority section. The second asks the child and reads the answer section. The two lists of names should match.
What a resolver does at a zone cut
When a resolver follows a delegation, it applies these steps:
- It sends the query to a server for the closest zone it knows about.
- If that server is not authoritative for the name, it replies with a referral: NS records in the authority section, and glue in the additional section when needed.
- The resolver picks one of the listed servers and repeats the query there.
- It stops when a server returns an authoritative answer (the
aaflag is set), an authoritative "no such name" or "no data" response, or an error.
Resolvers cache the NS records and glue they receive, so later lookups under the same zone skip the upper levels. The next chapters cover the full walkthrough and caching in detail.
Delegating a subdomain: a worked example
Suppose you run example.com and want the network team to manage lab.example.com. You need three steps.
- The network team creates a zone for
lab.example.comon its servers. The zone needs a SOA record and NS records at its apex. - You add NS records for
labto theexample.comzone. If the name servers are insidelab.example.com, add glue records too. - You check the result from both sides, with the commands shown earlier.
The child zone file might start like this:
$ORIGIN lab.example.com.
$TTL 3600
@ IN SOA ns1.lab.example.com. hostmaster.example.com. (
2026112701 ; serial
7200 ; refresh
3600 ; retry
1209600 ; expire
300 ) ; negative caching TTL
IN NS ns1.lab.example.com.
IN NS ns2.lab.example.com.
ns1 IN A 192.0.2.101
ns2 IN A 192.0.2.102
www IN A 192.0.2.110Note that ns1 and ns2 appear in both zones. The parent holds them as glue and the child holds them as authoritative data. They must agree.
Common errors
Lame delegation. The parent lists a server that does not actually serve the zone, or serves it without authority. Resolvers that pick that server get a failure or a non-authoritative reply and must retry elsewhere. Lookups become slow or intermittently fail. This often happens after a provider change when the old NS records were never removed from the parent.
Parent and child NS mismatch. The parent's list and the child's apex list differ. Resolvers may use either, depending on what they have cached, so behavior varies between networks. Update both together.
Missing glue. An in-zone name server has no glue at the parent. Lookups fail because the resolver cannot find the server's address.
Stale glue. You renumbered a name server but did not update the glue at the registrar. Resolvers keep sending queries to the old address.
A CNAME at a zone cut. A name cannot have both a CNAME and NS records. If you try to delegate eng while a eng CNAME record exists, the zone is invalid.
Only one name server. A single server is a single point of failure. Standard practice is at least two, on separate networks.
Summary
A zone is the unit of administration, and a domain may span many zones. Delegation is an NS record set in the parent zone that points to the child zone's servers. Glue records in the parent solve the circular dependency when a name server lives inside the zone it serves. Resolvers follow referrals down from the root and cache what they learn. Most delegation faults come from the parent and child disagreeing.
Exercise
The zone corp.example.org is served by ns1.corp.example.org and ns2.dns-host.net. Which of these name servers needs a glue record in the example.org zone, and why?
Show answer
Only ns1.corp.example.org needs glue. Its name is inside the zone being delegated, so a resolver would need to ask the zone's own servers to find its address, which is circular. ns2.dns-host.net is outside corp.example.org, so the resolver can look up its address through the net zone without glue.
Exercise
You run dig @a.gtld-servers.net example.com A +norecurse. The answer section is empty, the authority section lists NS records, and the aa flag is not set. What does this response tell you?
Show answer
It is a referral. The com server is not authoritative for example.com, so it points the resolver at the example.com name servers listed in the authority section. The resolver should send the same query to one of those servers.
Exercise
After moving DNS hosting, some users still reach the old provider's servers and get failures. The domain's own zone lists only the new servers. What is the most likely cause, and where do you fix it?
Show answer
The NS records at the parent (the TLD zone, controlled through the registrar) probably still list the old servers, or resolvers have them cached. Fix it by updating the delegation at the registrar, and keep the old servers answering until the old NS records' TTL has expired.