NS and SOA Records
Understand the two records that define a DNS zone: who answers for it, how delegation works and what each SOA timer does.
Key takeaways
- NS records exist in two places: in the parent zone as a delegation and at the top of the zone itself.
- The two sets should match, and every listed server should actually answer for the zone.
- A zone has exactly one SOA record, which carries a serial number and timers for secondary servers.
- The SOA record also limits how long resolvers remember that a name or record does not exist.
NS records name the servers that are authoritative for a zone. The SOA (start of authority) record holds the zone's administrative details: its primary server, a contact, a version number and several timers. Together they define who is in charge of a part of DNS and how copies of it behave.
You may never need to edit either one if you use a hosted DNS service. You do need to understand them when you change providers, delegate a subdomain, run your own name servers or try to work out why a domain is only half working.
NS records and delegation
example.com. 86400 IN NS ns1.example.net.
example.com. 86400 IN NS ns2.example.net. This says that two servers hold the official data for example.com. The value is always a hostname, and that hostname must have its own A or AAAA records. It should not be an alias.
The same information appears twice:
- In the parent zone. The
comzone holds NS records forexample.com. These come from the name servers you set at your registrar. They are how resolvers find you. - In your own zone. The servers you point to also publish NS records at the top of the zone. These are the authoritative version.
If the parent points to one provider and your edits go to another, nothing you change takes effect. This is one of the most common DNS puzzles: the dashboard shows the new record, but the domain is not delegated to that dashboard.
Glue records
Suppose example.com uses ns1.example.com. To find that server's address, a resolver would have to ask the servers for example.com, which is what it is trying to find. The parent breaks the circle by also publishing the server's address, called a glue record.
You usually set glue at the registrar, in a section named something like "host records" or "child name servers". If you change the address of such a server, update the glue as well, or resolvers will keep being sent to the old one. If your name servers belong to another domain, such as your DNS provider's, no glue of yours is needed.
Delegating a subdomain
To hand lab.example.com to different servers, add NS records for it inside the example.com zone:
lab.example.com. 3600 IN NS ns1.lab.example.com.
ns1.lab.example.com. 3600 IN A 192.0.2.80 From then on, the parent answers questions under lab with a referral. This lets another team or another platform manage its own names without access to the rest. When you retire it, remove the delegation, since a forgotten one pointing at a service you no longer control is a route to subdomain takeover.
The SOA record
example.com. 3600 IN SOA ns1.example.net. hostmaster.example.com. 2026120501 7200 3600 1209600 300 All timers are in seconds. In the example, secondaries check every two hours, retry after one hour and give up after two weeks without contact.
The contact field
hostmaster.example.com. means [email protected]. The first unescaped dot replaces the at sign. A mailbox that itself contains a dot needs it escaped with a backslash.
The serial
Secondaries compare serial numbers to decide whether to copy the zone again. Any increasing number works. The date-based style, year, month, day and a two-digit counter, is easy to read.
If you accidentally set a serial far too high, you cannot simply lower it: secondaries will consider the new one older. Fixing this means stepping the number forward in stages according to the serial arithmetic rules, or reloading the secondaries from scratch. Many hosted providers manage the serial for you and may use their own format.
The minimum field
Its name is historical. Today it works together with the SOA record's own TTL: resolvers cache a "does not exist" answer for the smaller of the two. A high value means a name you looked up before creating it may seem absent for a long time. See caching and TTL.
Choosing values
If your server software or provider fills these in, the defaults are usually reasonable. If you set them yourself, keep the relationships sensible:
| Timer | Guidance |
|---|---|
| Refresh | Hours is fine when change notifications work |
| Retry | Shorter than refresh |
| Expire | Long, commonly weeks, so a primary outage can be fixed |
| Negative TTL | Minutes to an hour for zones that change often |
Looking them up
dig example.com NS +short
dig example.com SOA +short
dig +trace example.com NS The trace output shows the delegation as the parent publishes it, then what your servers say. On Windows:
Resolve-DnsName example.com -Type NS
Resolve-DnsName example.com -Type SOA
nslookup -type=soa example.com To check that all servers agree, ask each one directly:
dig @ns1.example.net example.com SOA +short
dig @ns2.example.net example.com SOA +short Differing serials that persist suggest a secondary is not receiving updates. Check transfer permissions and that both UDP and TCP on port 53 pass between the servers. Some multi-provider setups intentionally use independent serials, so interpret the result in light of how your DNS is run.
How many name servers, and where
A domain should list at least two name servers, and many have more. The count matters less than their independence. Two names that lead to one machine, one rack or one network fail together.
Hosted DNS services commonly give you two to four names, each of which is answered from many locations using anycast. That covers most failures, though not a problem affecting the whole provider. Organizations that cannot tolerate that sometimes use two DNS providers at once, listing servers from both. This adds real work: the records must be kept identical at both, provider-specific features such as health-based answers may not translate, and signing with DNSSEC needs careful coordination.
For a small site, one reputable provider is a reasonable choice. Weigh the cost of an hour of unreachable email and web against the effort of keeping two systems in step.
Why resolvers care which NS set they believe
When a resolver is first referred to your domain, it has only the parent's list. Once it hears from your servers, it generally treats the zone's own NS set as the more authoritative one, though software behavior varies. If the two differ, some resolvers use one and some the other, and the same resolver may switch as entries expire.
The safe rule is to change both together. When adding a server, make sure it answers correctly before listing it anywhere. When removing one, take it out of both lists, wait for the longer of the two TTLs to pass, and only then switch the server off.
Who can change them
The two records are protected by different logins. The parent's delegation is changed through your registrar account. The zone's NS and SOA records are changed wherever the zone is hosted. Anyone who gains the registrar login can point the whole domain elsewhere, whatever your DNS host holds. Use multi-factor authentication on both accounts, and consider a registrar lock that blocks changes until you lift it. Preventing domain hijacking covers those defenses.
Typical faults
- Lame delegation: a listed server does not serve the zone, producing slow or failed lookups.
- Mismatched sets: parent and zone list different servers, so behavior depends on what a resolver has cached.
- Single point of failure: both names resolve to the same machine or network.
- Name server on an expired domain: if your NS names live under a domain that lapses, every domain relying on them is affected, and whoever registers it next could answer for you.
- Changing providers too fast: the old service is switched off while parent and resolver caches still point to it.
A quick health check
When you inherit a domain or finish a change, run through these questions. Do the names listed by the parent match the names in the zone? Does each of those names resolve to an address? Does each server answer for the domain with the authoritative flag set? Do the servers agree on the SOA serial, allowing for how your provider works? Is the contact mailbox one that somebody reads? Write the answers down with the date, so that the next person has a known good state to compare against.
Changing name servers safely
- Copy every record into the new provider and verify it by querying the new servers directly.
- If the domain is signed with DNSSEC, plan the signing handover first; a mismatch makes the domain fail for validating resolvers.
- Change the name servers at the registrar.
- Keep the old zone serving, with identical data, for at least a couple of days.
- Confirm traffic has moved before closing the old account.
How to migrate DNS without downtime expands on each step, and zone files and name servers shows where these records sit among the rest.