DNS records and TTLs in practice

Intermediate · 6 min

The DNS records an operator actually changes, why 'propagation' is just caches expiring, and how to move a service to a new IP without a long tail.

Before thisThe Linux server from an operator's seat

LearnThatStack · 6 min

DNS records and TTLs in practice

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by LearnThatStackReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • DNS 'propagation' is not a broadcast. Resolvers cache each answer for its TTL, and a change reaches a user only when their resolver's cached copy expires.
  • The authoritative server shows the full TTL you configured. A resolver shows the time left on its cached copy, counting down.
  • Before a migration, lower the record's TTL and wait at least the old TTL, so that when you switch, caches expire within minutes.
  • A CNAME points one name at another and cannot sit at the zone apex. A and AAAA map a name to addresses, MX routes mail, TXT carries verification and policy, CAA limits which CAs may issue.
  • Failed lookups are cached too, for the time set in the zone's SOA record, so querying a name before you create it can delay it.

“We changed DNS an hour ago”

You move the notes API to a new server and update its A record. Your own checks pass. An hour later support tickets say the site is down, and they all come from users still reaching the old server, which you just shut off. Someone says “DNS takes 48 hours to propagate” and everyone shrugs.

That explanation is wrong in a useful way. Nothing propagates. The new answer was live the moment you saved it. What you are waiting for is caches to expire, and you control how long that takes. The protocol itself, resolvers and the lookup chain, is covered in DNS and HTTP. This lesson is about the records you edit and the clock attached to each.

The records you actually touch

Record Says Typical use
A / AAAA this name has this IPv4 / IPv6 address your servers, load balancers
CNAME this name is an alias for that name www pointing at a CDN hostname
MX mail for this domain goes to these hosts your mail provider
TXT free text domain verification, SPF, DKIM
NS these servers are authoritative for the zone set at your registrar
SOA zone metadata, including the negative-cache time managed by your DNS provider
CAA only these CAs may issue certificates ties into TLS

Every record carries a TTL, time to live, in seconds: how long anyone who receives the answer may reuse it without asking again.

Looking at real answers

I queried GitHub’s records with dig through Cloudflare’s public resolver, 1.1.1.1 (some lines trimmed):

$ dig +noall +answer A github.com @1.1.1.1
github.com.		9	IN	A	4.187.247.160
$ dig +noall +answer CNAME www.github.com @1.1.1.1
www.github.com.		3600	IN	CNAME	github.com.
$ dig +noall +answer MX github.com @1.1.1.1
github.com.		300	IN	MX	0 github-com.mail.protection.outlook.com.
$ dig +noall +answer NS github.com @1.1.1.1
github.com.		3600	IN	NS	dns1.p08.nsone.net.
github.com.		3600	IN	NS	ns-1283.awsdns-32.org.
$ dig +noall +answer SOA github.com @1.1.1.1
github.com.		2179	IN	SOA	dns1.p08.nsone.net. hostmaster.nsone.net. 1656468023 43200 7200 1209600 3600

Several things show up. The AAAA query returned no records at all, so GitHub’s main domain has no IPv6 address. github.com is served by two DNS providers at once, NS1 and Route 53, so one provider’s outage does not take the name down. And the 9 on the A record is not GitHub’s TTL. It is how many seconds 1.1.1.1 had left on its cached copy.

To see the real TTL, ask an authoritative server directly. Then compare two resolvers:

$ dig +noall +answer A github.com @dns1.p08.nsone.net
github.com.		60	IN	A	4.187.247.160
$ dig +noall +answer A github.com @8.8.8.8
github.com.		57	IN	A	4.187.247.160
$ dig +noall +answer A github.com @1.1.1.1
github.com.		42	IN	A	135.235.149.144

The configured TTL is 60 seconds. The two public resolvers each hold a copy with different time left, and they hold different addresses: GitHub hands out different IPs to spread load. A short TTL is what makes that work.

The countdown is easiest to see on a long TTL. I queried Wikipedia through Google’s resolver, waited 20 seconds, and queried again:

en.wikipedia.org.	21401	IN	CNAME	dyna.wikimedia.org.
dyna.wikimedia.org.	75	IN	A	103.102.166.224
  (20 seconds later)
en.wikipedia.org.	21381	IN	CNAME	dyna.wikimedia.org.
dyna.wikimedia.org.	55	IN	A	103.102.166.224

Both dropped by exactly 20. Wikimedia’s own name server returns 86400 for the CNAME and 180 for the A record. The alias almost never changes, so it caches for a day. The address can change for failover, so it caches for three minutes.

Moving a service without the long tail

The fix for the opening story is a plan:

  1. Days before, lower the TTL on the record you will change, for example from 86400 to 300. Then wait at least the old TTL, since caches already hold the record with its day-long timer.
  2. Switch the record to the new address. Keep the old server running.
  3. Verify against the authoritative server with dig @ns1.yourprovider, not your laptop’s resolver.
  4. Wait the short TTL, watch traffic drain from the old server, then shut it down.
  5. Raise the TTL again once things are stable.

Two traps. A CNAME cannot coexist with other records for the same name, so you cannot put one on the bare domain example.com. Providers offer an ALIAS or “CNAME flattening” record type for that case. And failed lookups are cached as well. The last number in the SOA above, 3600, caps how long a resolver may remember “this name does not exist”. If you query api.example.com before creating it, that “no” can stick for up to an hour.

About the video

“DNS Explained - Stop Waiting 48 Hours for Changes” is from LearnThatStack, published December 2025, 5 minutes 47 seconds. Its chapters cover DNS caching, verifying changes with dig, record types (A, CNAME, MX, TXT, NS), a migration playbook and common traps. That is very close to this lesson’s scope. It is a small channel. English was judged from the title, description, channel and its English auto-caption track. DNSimple’s video in deeper walks through the TTL lifecycle step by step.

Where this fits

Clients can now find your server. In front of the application there is usually one more hop, a proxy that spreads requests across several copies of it: reverse proxies and load balancers with nginx.

Check yourself

  1. 01You changed an A record ten minutes ago. Your laptop sees the new IP, a colleague's sees the old one. Is DNS broken?

    No. Their resolver still holds the old answer and will keep it until its TTL runs out. Querying the authoritative server directly confirms the change is live.

  2. 02A record has a TTL of 86400. You plan to move the server tomorrow. What do you do today?

    Lower the TTL to something short, such as 300, now. Caches that already hold the record keep it for up to a day, so the short TTL must be in place at least that long before the switch.

  3. 03Why does dig against 1.1.1.1 show a different TTL each time you run it?

    1.1.1.1 is a caching resolver. It reports how many seconds remain before its cached copy expires, which counts down between queries.

  4. 04Why can't you put a CNAME on example.com itself?

    A CNAME cannot coexist with other records for the same name, and the zone apex must have SOA and NS records. Providers offer ALIAS or CNAME flattening to get the same effect.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark