Chapter 3 · Lesson 13 of 22
Domains and HTTPS

What is a DNS zone? Zones, SOA and NS records

A DNS zone is the portion of the DNS namespace that one set of nameservers is responsible for, described by a zone file of records starting with an SOA and NS records.

By the end you will

Explain what a DNS zone is, read its SOA and NS records and decide whether a subdomain needs its own zone.

Time
12 min
Level
Intermediate
Check
4 questions
You need
  • dig installed (dnsutils or bind-utils)
  • A domain you can query, such as example.com

A DNS zone is the part of the DNS namespace that one set of nameservers is responsible for. If you own example.com and keep all its records at one DNS provider, that provider hosts a single zone called example.com. The zone is the thing you edit when you add an A record or an MX record. A domain is a name; a zone is the administrative unit that stores the records for it.

How it works#

DNS is a tree. The root sits at the top, then top-level domains such as com, then names like example.com, then names below that. Responsibility for each branch is handed down. The com servers do not know your records. They only know which nameservers are authoritative for example.com and refer resolvers to them.

A zone covers a name and everything under it, except any part that has been delegated to someone else. If you never delegate, example.com, www.example.com and api.example.com all live in one zone. If you delegate app.example.com, that name and everything beneath it moves into a separate zone with its own nameservers.

The records for a zone are often written in a zone file. Providers hide the file behind a web form or API, but the model is the same: a list of records, each with a name, a TTL, a type and a value.

Zone vs domain#

Think of a domain as an address and a zone as the filing cabinet that holds the records for it. Most small sites have exactly one zone per registered domain, so people use the words interchangeably. They split apart in two cases:

  • A large organization delegates parts of its name to other teams, so one domain spans many zones.
  • A reverse zone such as one under in-addr.arpa maps IP addresses back to names and is a zone with no matching domain you registered.

The registrar is a third party. It records which nameservers are authoritative for your domain in the parent zone (com for example.com). The zone itself lives wherever those nameservers say it does.

The SOA record#

Every zone has one SOA (start of authority) record at its top. Ask for it with dig:

bash
dig example.com SOA +noall +answer

The answer has one line with the zone name, a TTL, the type, and then seven fields in order: the primary nameserver, the responsible mailbox (written with a dot instead of the at sign), a serial number, and the refresh, retry, expire and minimum timers.

  • Primary nameserver: the server that holds the master copy.
  • Serial: a number that increases whenever the zone changes. Secondary servers compare it to know when to copy the zone again.
  • Refresh, retry, expire: timers that control how secondary servers poll and when they give up on a dead primary.
  • Minimum: today this is used as the negative caching time, how long resolvers may remember that a name does not exist. See TTL and DNS caching explained.

NS records and the apex#

The NS records at the top of the zone name the authoritative nameservers:

bash
dig example.com NS +noall +answer

A zone normally lists at least two nameservers so one outage does not take the domain offline. The top name of the zone, example.com itself, is called the apex (or root of the zone, or bare domain). It always carries the SOA and NS records. That is the reason a CNAME cannot be placed there: a CNAME means “this name is an alias for another name and has no other records”, which conflicts with the SOA and NS that must exist. The fix is covered in CNAME flattening and ALIAS records.

Delegating a subdomain into its own zone#

Delegation is how a zone gives up part of its tree. To delegate app.example.com, add NS records for the name app in the example.com zone:

output
app.example.com.   3600  IN  NS  ns1.other-dns.example.net.
app.example.com.   3600  IN  NS  ns2.other-dns.example.net.

From then on, resolvers that ask about anything under app.example.com are sent to those servers. The other provider must have a zone called app.example.com, with its own SOA and NS, or queries will fail. Parent and child NS sets should match, since resolvers may use either.

People delegate to let another team or tool manage a branch, to give a platform control of its own records, or to point an automation at a narrow slice so a bug cannot touch the main domain. If a name is delegated, any other records you add for it or below it in the parent zone are ignored by resolvers that follow the delegation.

Who hosts the zone#

Three parties are involved, and they are often one company:

  1. The registrar, where you pay for the name and set the nameservers.
  2. The DNS provider, whose servers answer queries for your zone.
  3. You, who edit the records through the provider’s interface.

Changing nameservers at the registrar moves the zone to a new host. You must recreate every record there first, because the old zone does not move on its own. See DNS propagation myths for why that switch is slower than a normal record edit.

Check it worked#

Find out which servers are authoritative, then ask one directly:

bash
dig example.com NS +short
dig @ns1.example.net example.com SOA +noall +answer

The first command lists the nameserver names. The second sends your question to one of them instead of your local resolver. The answer should carry the aa flag (authoritative answer) when you drop the +noall options and read the header. To see the delegation chain from the root down, run dig +trace example.com. See Check DNS with dig for the full toolkit.

Edge cases and gotchas#

  • Lame delegation: if the parent lists a nameserver that does not actually serve your zone, some queries fail while others work. Check every NS name with dig @<ns> example.com SOA.
  • Mismatched NS sets: the parent zone and the zone itself can list different nameservers. Resolvers may follow either, so keep them identical.
  • Orphaned records after a move: switching providers without copying records first makes the new zone empty, and your site disappears.
  • Delegated names hide parent records: an A record for app.example.com in the parent zone is dead once NS records for app exist.
  • Serial confusion: editing a self-hosted zone file without raising the serial leaves secondary servers serving stale data.
  • Registrar vs DNS host: editing records at your registrar does nothing if its nameservers are not the ones in use.

Troubleshooting#

SymptomLikely causeFix
New record never appearsYou edited a zone at a provider that is not authoritativeRun dig example.com NS +short and edit the zone at that provider
SERVFAIL for a delegated subdomainThe child zone does not exist at the delegated nameserversCreate the zone there, with its SOA and NS
Some lookups return old data, some newParent and child NS sets differMake both lists identical
Site vanished after changing nameserversRecords were not copied to the new zoneRecreate records at the new provider, then compare answers with dig
CNAME rejected at the apexSOA and NS must share that nameUse an ALIAS or flattening feature, or an A record
Zone changes not seen by secondary serversThe SOA serial was not increasedIncrease the serial and reload

Quick reference#

bash
dig example.com SOA +noall +answer     # zone settings and serial
dig example.com NS +short              # authoritative nameservers
dig @ns1.example.net example.com A     # ask one server directly
dig +trace example.com                 # follow delegation from the root

Next#

Continue with TTL and DNS caching explained.

Check what you learned4 questions
1What is the difference between a domain and a zone?
2Which two record types must exist at the top (apex) of every zone?
3How do you hand app.example.com to a different DNS provider as its own zone?
4Which command shows the SOA record of a zone?

Frequently asked questions

What is the difference between a DNS zone and a domain?

A domain is a name in the DNS tree. A zone is the slice of that tree managed by one set of authoritative nameservers. One domain can contain several zones when subdomains are delegated.

What is in a DNS zone file?

A zone file is a text list of resource records for the zone. It starts with an SOA record, lists the NS records, and then holds A, AAAA, CNAME, MX, TXT and other records.

Do I need to edit the SOA record myself?

Usually not. Most DNS providers manage the SOA for you and bump the serial on each change. You mainly read it to find the primary nameserver and the negative caching time.

Who hosts my DNS zone?

Whoever runs the nameservers listed in your domain's NS records. That is often your registrar by default, but you can move it to a separate DNS provider by changing the nameservers at the registrar.

Sources

View MD Edit
Share
Helpful?
Progress is saved in this browser only.

Keep going: guides and tutorials

View MD Edit
Share
Helpful?
Run this on your own server

Levelrail deploys apps from git with health-checked releases and one-click rollback.

docker pull ghcr.io/glincker/levelrail:latest Install Levelrail From GLINR Studios