What Are Nameservers? How Nameservers Work

Nameservers are the servers that hold the DNS records for a domain. They answer queries from resolvers worldwide, directing traffic to the correct web servers, mail servers, and other services.


Nameservers are the DNS servers responsible for holding and serving all the DNS records for a domain. When someone visits your website, their browser ultimately contacts your domain's nameservers to find out where the site is hosted. Understanding how nameservers work is essential for managing domains, switching hosting providers, and diagnosing DNS issues.

What Is a Nameserver?

A nameserver (also written as name server or NS) is a specialised DNS server that stores the zone file for a domain. The zone file is the database of all DNS records associated with a domain, including A records (IP addresses), MX records (mail servers), TXT records (verification and policy data), and CNAME records (aliases).

When the global DNS system needs to resolve a name within your domain, it eventually reaches your nameservers and asks them directly. Because they hold the official, definitive records for your domain, they are called authoritative nameservers.

Nameserver hostnames typically follow a pattern like:

text
; Typical nameserver format ns1.example-hosting.com ns2.example-hosting.com ; Cloudflare example alice.ns.cloudflare.com bob.ns.cloudflare.com ; AWS Route 53 example ns-123.awsdns-45.com ns-678.awsdns-90.org

Authoritative vs. Recursive Nameservers

Two fundamentally different types of nameservers exist in the DNS ecosystem, and confusing them is a common source of misunderstanding:

TypeAlso CalledRoleExamples
AuthoritativeAuthoritative NS, zone NSHolds the official DNS zone for a domain; answers with definitive recordsCloudflare, AWS Route 53, your hosting provider's NS
RecursiveResolver, recursive resolver, caching resolverAccepts queries from end users; walks the DNS tree on their behalf; caches results8.8.8.8 (Google), 1.1.1.1 (Cloudflare), your ISP's resolver

When you change the nameservers for your domain at your registrar, you are changing which authoritative nameservers hold your zone. Recursive resolvers (like 8.8.8.8) are the servers your computer talks to — they do the legwork of finding and returning the authoritative answer.

How Nameservers Answer a DNS Query

A simplified lookup for www.example.com proceeds as follows:

  1. Your computer sends a query to its configured recursive resolver (e.g., 8.8.8.8).
  2. The resolver queries a DNS root server, which says: “I don't know, but ask Verisign — they handle .com.”
  3. The resolver asks Verisign's TLD nameservers for example.com, which say: “Ask ns1.example-hosting.com.”
  4. The resolver asks ns1.example-hosting.com for the A record of www.example.com.
  5. The authoritative nameserver returns the IP address from its zone file.
  6. The resolver caches the answer (for the duration of the TTL) and returns it to your computer.
The referral at step 3 comes from NS records

The TLD nameservers know which authoritative nameservers to refer queries to because your registrar published NS records in the TLD's database when you set or updated your nameservers. This is why a nameserver change starts at your registrar, not in your DNS zone.

NS Records Explained

An NS record (Nameserver record) lists the authoritative nameservers for a domain. Every domain must have at least two NS records for redundancy. NS records appear both in the parent zone (published by the registry/registrar) and within the domain's own zone file.

bash
; NS records in a zone file example.com. 3600 IN NS ns1.example-hosting.com. example.com. 3600 IN NS ns2.example-hosting.com. ; Query NS records with dig dig example.com NS ; Query NS records against a specific resolver dig example.com NS @8.8.8.8 ; Query with nslookup nslookup -type=NS example.com

You can also look up NS records for any domain instantly with the ShowDNS DNS Lookup tool by selecting the NS record type.

Primary vs. Secondary Nameservers

Historically, DNS used a primary/secondary model where the primary nameserver held the master zone file and secondary nameservers received copies via zone transfers. In modern managed DNS services, this distinction is largely abstracted away — all nameservers are updated simultaneously from a central control plane, and the ns1 / ns2 naming is cosmetic rather than indicating a hierarchy.

You should always configure at least two nameservers for redundancy. If one nameserver is unreachable, resolvers will try the others. Having all nameservers at the same provider is a single point of failure that some enterprises mitigate by using a secondary DNS provider.

How Changing Nameservers Moves Your DNS

When you switch hosting providers or move your DNS management (for example, to Cloudflare), you change the authoritative nameservers. Here is what happens:

  1. You log into your domain registrar and update the NS records to point to the new nameservers.
  2. The registrar notifies the TLD registry, which updates its delegation records.
  3. Recursive resolvers worldwide begin querying the new nameservers once their cached NS records expire.
  4. The new nameservers must already have your DNS zone configured with all the correct records before you switch.
Export your DNS records before switching nameservers

Before changing nameservers, export every DNS record from your current provider. The new nameservers will not automatically inherit your existing records. Missing records after a switch can cause your website, email, or other services to stop working.

Nameserver Propagation Time

Nameserver changes propagate more slowly than standard DNS record changes because they involve the TLD registry's database, which has its own TTL. Typically:

  • Most resolvers worldwide see the new nameservers within 2–6 hours.
  • Full global propagation can take up to 24–48 hours in rare cases involving long-cached NS records.
  • The TLD's NS delegation TTL is usually 48 hours, but many registries now use shorter values (2–24 hours).

You can monitor nameserver propagation in real time using the ShowDNS DNS Propagation Checker. Select the NS record type and enter your domain to see which resolvers worldwide are returning the new nameservers.

bash
# Check which nameservers are currently authoritative for a domain dig example.com NS @8.8.8.8 # Trace the full delegation path from the root dig example.com NS +trace # Compare what different resolvers return during propagation dig example.com NS @8.8.8.8 # Google dig example.com NS @1.1.1.1 # Cloudflare dig example.com NS @9.9.9.9 # Quad9

Verifying Nameservers Are Correct

After any nameserver change, verify the configuration is complete by checking that:

  • The NS records returned by dig match the nameservers you set at your registrar.
  • The nameservers are answering authoritatively (look for the aa flag in the dig output flags section).
  • All expected DNS records (A, MX, TXT, CNAME) are present and correct at the new nameservers.

Frequently Asked Questions

What is the difference between a nameserver and a DNS record?

A nameserver is the server that stores and serves DNS records. DNS records (such as A, MX, TXT, CNAME) are the individual entries within the nameserver's zone file that tell the world where your website, email, and other services are located. Changing a nameserver changes who hosts your zone; changing a DNS record changes the data within that zone.

Do I need to manage nameservers myself?

In most cases, no. Your hosting provider or a managed DNS service (Cloudflare, AWS Route 53, etc.) provides nameservers and manages the underlying infrastructure. You simply point your domain to their nameservers at your registrar and configure your DNS records through their control panel.

Why do I need at least two nameservers?

Redundancy is required by DNS standards (RFC 1034). If you only have one nameserver and it goes offline, all DNS resolution for your domain fails and your website and email become unreachable. With two or more nameservers, resolvers can try the next one if the first is unavailable.

Can I use nameservers from two different providers?

Yes. Using nameservers from two different DNS providers (secondary DNS) improves resilience against provider outages. Both providers must serve identical zone data, either through AXFR zone transfers or via your DNS management tool pushing updates to both providers simultaneously.

How do I find the nameservers for a domain?

Run dig example.com NS @8.8.8.8 from the command line, use whois example.com and look for the Name Server fields, or use the ShowDNS DNS Lookup tool and select NS as the record type.

Related Articles