DNS (the Domain Name System) is the lookup service that turns a name like example.com into the data other systems need: an IP address for a website, a mail server for email, or a text string that proves ownership. Each piece of data lives in a record of a specific type, and each record carries a TTL that tells resolvers how long they may cache it. That cache is the real reason DNS changes seem to "take time".

What DNS does

Computers route traffic by IP address, but people remember names. When a browser needs www.example.com, it asks a recursive resolver, usually run by your ISP or a public provider. If the resolver has no fresh answer cached, it works down the hierarchy: the root servers point to the .com servers, which point to the authoritative name servers for example.com. Those authoritative servers hold your zone, the set of records you manage in your DNS provider's dashboard.

The key idea is the split between the authoritative server, which is the source of truth, and resolvers, which keep temporary copies. Almost every surprise in DNS comes from forgetting that second group exists.

The core record types

Here is a small zone snippet using documentation-reserved addresses. Real zones will use your own values.

$TTL 3600
example.com.        IN  A      192.0.2.10
example.com.        IN  AAAA   2001:db8::10
www.example.com.    IN  CNAME  example.com.
example.com.        IN  MX     10 mail1.example.com.
example.com.        IN  MX     20 mail2.example.com.
example.com.        IN  TXT    "v=spf1 include:_spf.example.net ~all"

A and AAAA

An A record maps a name to an IPv4 address. An AAAA record does the same for IPv6. Clients that support both will usually try IPv6 first, so if you publish an AAAA record, the server must actually answer on that address. A stale or wrong AAAA record is a classic cause of "works for some visitors, not others".

CNAME

A CNAME says "this name is an alias for another name". In the snippet, www.example.com follows whatever example.com resolves to. It is handy when a hosting provider gives you a hostname that may change IP addresses over time, because you point at their name and they maintain the addresses.

A CNAME has two firm limits. First, a name with a CNAME cannot have any other record type at the same name. Second, because the zone apex (example.com itself) must carry SOA and NS records, you cannot put a CNAME there. Some providers offer proprietary "ALIAS" or "ANAME" or "CNAME flattening" features that behave like an apex CNAME by resolving the target on their side and returning A records, but those are provider features, not standard record types.

MX

An MX record names the server that accepts email for the domain. The number is a priority: lower numbers are tried first. With the records above, senders try mail1 (10) first and fall back to mail2 (20) if it is unreachable. Equal numbers share load. An MX target must be a hostname with its own A or AAAA record, not an IP address and not a CNAME.

TXT

A TXT record holds free-form text. Three common uses:

  • SPF: a record listing which servers may send mail for your domain, so receivers can spot forged senders.
  • DKIM: a public key published under a selector name, which receivers use to verify a cryptographic signature on outgoing mail.
  • Domain verification: services such as search consoles, email providers and certificate authorities ask you to add a specific string to prove you control the domain.

The exact values always come from the service you are configuring, so copy them exactly rather than typing them by hand. A domain should have only one SPF record; multiple SPF records cause validation failures.

TTL and why propagation is really caching

Every record has a TTL (time to live) in seconds. A TTL of 3600 means a resolver may reuse its copy for up to an hour before asking again. When you edit a record, nothing is pushed out to the world. The authoritative server simply starts giving the new answer, and each resolver switches over only when its cached copy expires. That is why different people see different answers for a while, and why "propagation" is better understood as caches expiring at different moments.

The practical consequence: the worst-case delay is roughly the old TTL, not the new one. If the old record had a TTL of 86400 (one day), some resolvers may keep serving it for up to a day after the change. Some resolvers and operating systems also cache a little beyond the TTL, and browsers keep their own short caches, so allow a margin.

Checking records with dig and nslookup

Both tools query a resolver and print the answer. These example commands work on most systems with dig or nslookup installed:

dig example.com A
dig example.com AAAA +short
dig example.com MX
dig example.com TXT
dig www.example.com CNAME
dig NS example.com
dig @ns1.example.net example.com A

nslookup -type=MX example.com
nslookup -type=TXT example.com
nslookup example.com 8.8.8.8

The form with @ns1.example.net queries a specific server directly. Asking your authoritative name server (find it with the NS query) shows what you have actually published, free of resolver caches. Asking a public resolver shows what the wider internet currently sees. Comparing the two tells you whether a problem is a wrong record or just a cache that has not expired. In dig output, the number in the answer line before the record type is the remaining TTL for that cached copy.

For a quick browser-based check without a terminal, the free DNS tools on this site can look up record types for a domain.

Checklist for moving a site or email

  1. Find out which provider hosts your DNS by running dig NS yourdomain. Edit records only there.
  2. Record every existing record (export the zone if possible) before changing anything.
  3. At least one old-TTL period ahead of the move, lower the TTL on the records you will change to something like 300.
  4. Set up the new server or mail service fully and test it before switching, for example by using the new IP directly or a hosts-file entry.
  5. Change the records. For email, add the new MX, SPF, and DKIM records together.
  6. Verify with dig against both your authoritative server and a public resolver.
  7. Keep the old server running until the old TTL has passed, then raise the TTL again.
  8. If the move also changes the address in HTTPS setups, confirm the certificate matches the new host. See SSL certificate errors: how to diagnose them.

Common mistakes

  • Trailing dots. In a zone file, a name ending in a dot is fully qualified; without it, the zone name is appended. Writing mail1.example.com inside the example.com zone can become mail1.example.com.example.com. Many dashboards add the dot for you, so check how yours treats it.
  • CNAME plus MX at the same name. A CNAME excludes every other record at that name, so email for the domain breaks or behaves unpredictably. Use A/AAAA records at the apex instead.
  • Forgetting to lower the TTL beforehand. Lowering it at the moment of the change does not help, because resolvers already hold the long-lived copy.
  • Editing the wrong DNS host. Your registrar may show a zone editor, but if the domain's NS records point to another provider, those edits have no effect. The NS records decide who is authoritative.
  • Several SPF records. Merge them into one TXT record.

Frequently Asked Questions

How long do DNS changes take?

Typically about as long as the old record's TTL, plus some margin. New records that did not exist before can appear quickly, though a resolver that recently cached a "does not exist" answer may hold that for a while too.

Can I use a CNAME on my root domain?

Not under the standard. The root must hold SOA and NS records, and a CNAME cannot coexist with them. Use A and AAAA records, or a provider's alias-style feature if it offers one.

What does the number in an MX record mean?

It is the preference value. The server with the lowest number is tried first; higher numbers are fallbacks.

Why does dig show a different answer than my browser?

They may be using different resolvers with different cached copies, and browsers and operating systems add their own caches. Query the authoritative server directly to see the published truth.