What Is DNS and How Does It Work?

DNS (Domain Name System) is the internet's phone book — it translates domain names into IP addresses. When you type yoursite.com into your browser, DNS converts that name into the server's IP address (e.g., 185.12.34.56) so the browser can connect to the right server.

This lookup happens in milliseconds: your computer checks its own cache first, then your internet provider's DNS server, and — if needed — the domain's authoritative nameserver. The authoritative nameserver is the server that actually hosts your domain's DNS records, and it's usually provided by your hosting company or a CDN service like Cloudflare.

💡 Tip: You can manage your DNS records independently of the company you registered your domain with. Your domain can sit with one company while your hosting sits with another — what matters is that your nameservers point to the right place. To compare domain prices, check out our domain price comparison page.

A and AAAA Records: Pointing a Domain to a Server

An A record (Address) points a domain name to an IPv4 address. It's the most basic and most commonly used DNS record. An AAAA record does the same job for IPv6 addresses.

yoursite.com.        3600    IN    A       185.12.34.56
www.yoursite.com.    3600    IN    A       185.12.34.56
yoursite.com.        3600    IN    AAAA    2a01:4f8:1c2b::1

The fields here are, in order: record name, TTL (in seconds), class (IN), record type, and target IP. When you buy hosting, the provider gives you the server's IP address; if you use cPanel, you point the A record to that IP from the Zone Editor section.

Typical use cases:

  • @ (root domain) → your hosting server's IP
  • www → the same IP, or a CNAME to the root domain
  • Subdomains like panel or api → different server IPs

To compare server performance across different hosting companies, take a look at our hosting comparison page.

CNAME Records: Creating an Alias

A CNAME (Canonical Name) record points one domain name to another domain name — it references a name instead of an IP. Even if the target domain's IP changes, you never need to update your CNAME record.

www.yoursite.com.     3600    IN    CNAME    yoursite.com.
blog.yoursite.com.    3600    IN    CNAME    yoursite-blog.netlify.app.
shop.yoursite.com.    3600    IN    CNAME    shops.myshopify.com.
⚠️ Note: You cannot add a standard CNAME record to the root domain (yoursite.com) — the DNS standard doesn't allow it, because the root domain must also carry MX and NS records. For the root domain, use an A record or the ALIAS/ANAME record type offered by your provider.

MX Records: Email Routing

An MX (Mail Exchange) record determines which mail server incoming email for your domain gets delivered to. The server with the lower priority value is tried first.

# If you use hosting-based email:
yoursite.com.    3600    IN    MX    0     mail.yoursite.com.

# If you use Google Workspace:
yoursite.com.    3600    IN    MX    1     smtp.google.com.

You can host your website on one server and your email on an entirely different service: the A record points to your hosting, the MX record points to your mail service. We've compared corporate email options in detail in our mail hosting guide.

TXT Records: SPF, DKIM, and DMARC

A TXT record holds free-form text; its most critical use is email authentication. If any of these three records is missing, your emails are likely to land in the spam folder:

1. SPF — declares which servers are allowed to send email on behalf of your domain:

yoursite.com.    IN    TXT    "v=spf1 +a +mx include:_spf.google.com ~all"

2. DKIM — verifies outgoing email with a cryptographic signature. The key is generated by your mail server (created automatically in cPanel):

default._domainkey.yoursite.com.  IN  TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3..."

3. DMARC — specifies what happens to emails that fail SPF/DKIM verification:

_dmarc.yoursite.com.  IN  TXT  "v=DMARC1; p=quarantine; rua=mailto:dmarc@yoursite.com"

Start with p=none and monitor the reports; once you're confident there are no issues, move to p=quarantine and finally p=reject. Since 2024, Google and Yahoo have required DMARC for domains that send bulk email.

TXT records are also used for domain ownership verification with services like Google Search Console and Microsoft 365.

NS Records and Changing Nameservers

An NS (Name Server) record specifies which servers manage your domain's DNS records. You change nameservers when you switch hosting providers or move to Cloudflare:

yoursite.com.    IN    NS    ns1.hostingprovider.com.
yoursite.com.    IN    NS    ns2.hostingprovider.com.

Nameserver changes are made from your domain registrar's panel — not from the DNS zone itself. After the change, all of your old DNS records become invalid; you need to recreate your A, MX, and TXT records under the new nameserver. Getting the order of these steps right matters when migrating a site; see our guide to migrating a site without downtime for details.

TTL and DNS Propagation

TTL (Time To Live) determines how many seconds a DNS record stays cached on DNS servers around the world. Propagation is the process of that change spreading across the globe.

TTL Value Duration When to Use It
300 5 minutes Before a migration, or for records that change often
3600 1 hour The ideal balance for everyday use
86400 24 hours Stable records that rarely change

Practical tip: Lower the TTL to 300 24-48 hours before migrating your site. After the move, old caches clear within 5 minutes and downtime drops to almost zero. Once the migration is finished, raise the TTL back to 3600.

A nameserver change, on the other hand, can take 1-24 hours (rarely up to 48 hours) regardless of TTL, because caching at the top-level (TLD) servers comes into play.

DNS Lookup Tools

You can check whether your records have propagated correctly using these tools:

  • dig (Linux/macOS terminal) — the most reliable method:
# Query the A record
dig yoursite.com A +short

# Query MX records
dig yoursite.com MX +short

# Query via Google DNS (bypasses the local cache)
dig @8.8.8.8 yoursite.com A +short

# View TXT (SPF) records
dig yoursite.com TXT +short
  • nslookup (Windows) — nslookup -type=MX yoursite.com
  • dnschecker.org — checks propagation from 40+ locations worldwide
  • mxtoolbox.com — checks MX, SPF, DKIM, DMARC, and blacklist status

If you'd like to continuously monitor your site's availability, you can track providers' live uptime data on our hosting status page.

Frequently Asked Questions

How long does it take for a DNS change to take effect?

Regular record changes (A, MX, TXT) propagate anywhere from 5 minutes to 24 hours, depending on the TTL. Nameserver changes typically take 1-24 hours. You can shorten this window by lowering the TTL before making the change.

What is the difference between an A record and a CNAME?

An A record points a domain directly to an IP address, while a CNAME points to another domain name instead. If the target server's IP changes often, a CNAME requires no maintenance; for the root domain, only an A record can be used.

Why are my emails ending up in the spam folder?

The most common cause is missing SPF, DKIM, and DMARC records. Configure all three correctly and test them with mxtoolbox.com. You should also check whether your server's IP is on a blacklist.

Do I need to change hosting to use Cloudflare?

No. Moving to Cloudflare is just a nameserver change; your hosting stays exactly the same. Cloudflare automatically imports your existing records and adds CDN, caching, and DDoS protection on top.

Should I manage DNS through my hosting provider or my domain registrar?

Either works; DNS is managed wherever your nameservers point. If you migrate sites often, managing DNS at your registrar or through an independent DNS service like Cloudflare is more flexible — your DNS panel stays the same even if you switch hosting.