Why a new TTL never reaches caches that already have the record
Reading the remaining TTL with dig
BASH
# List the authoritative nameservers for the zone
dig +short NS example.com
# Ask one authoritative server directly: shows the TTL as configured now
dig +noall +answer example.com A @ns1.example.net
# Ask a recursive resolver: shows the remaining TTL on its cached copy
dig +noall +answer example.com A @1.1.1.1ns1.example.net with a nameserver returned by the first command, and repeat the second query for every nameserver in that list. The output looks something like this.
Illustrative output format (authoritative first, then resolver):
TEXT
example.com. 300 IN A 203.0.113.10
example.com. 61842 IN A 198.51.100.20How far ahead to lower the TTL
A cutover order that holds up in production
- Read the current TTL from an authoritative server and write it down. That number is how long your preparation window must be.
- Lower the TTL, for example to 300, at least one full old TTL before the planned move. Confirm the new value on every authoritative nameserver.
- Wait out the old TTL. Spot-check a few resolvers. Their remaining TTL should now never exceed the new low value.
- Do the final data sync, then change the record to the new IP.
- Keep the old server online and serving correctly, or proxying to the new one, for well beyond the new TTL. Watch its access logs until traffic tapers off to almost nothing.
- Once the new server is stable, raise the TTL back to a normal value. Leaving it at 300 permanently means more queries to your DNS and less tolerance if your DNS provider has a problem.
