🌐 DNS Deep Dive 9 分钟阅读

DNS Propagation & TTL: Why Changes Take Time

Understand how DNS caching, TTL values, and propagation delays affect domain changes and how to minimize downtime during migrations.

What Is DNS Propagation?

When you change a DNS record (e.g., update an A record to point to a new server), the change does not take effect instantly worldwide. DNS propagation is the time it takes for all DNS resolvers and caches across the internet to reflect the updated record.

Propagation is not a broadcast — there is no mechanism to push changes. Instead, caches expire naturally based on TTL values.

How TTL Works

TTL (Time to Live) is a value set on every DNS record that tells resolvers how long (in seconds) to cache the response before re-querying the authoritative server.

TTL Value Duration Use Case
300 5 minutes During migrations, frequent changes
3600 1 hour Standard websites
86400 24 hours Stable records (MX, rarely-changing A)
# Check current TTL for a domain
dig example.com A +noall +answer
# example.com.  3600  IN  A  93.184.216.34
#               ^^^^  TTL in seconds

Why Propagation Is Not Instant

Even after you update a record and the authoritative server responds with the new value:

  1. Resolver caches — Every ISP resolver caches records until TTL expires. A 24-hour TTL means some users see the old record for up to 24 hours.
  2. Browser caches — Browsers cache DNS independently (Chrome: ~1 minute, Firefox: ~60 seconds).
  3. OS caches — Operating systems maintain their own DNS cache.
  4. CDN/proxy caches — Cloudflare, Fastly, and other CDNs may cache DNS separately.

Minimizing Downtime During Migrations

Before migration:

# Step 1: Lower TTL 24-48 hours before the change
# Set TTL to 300 (5 minutes) on the records you plan to change
# Wait for the old high-TTL cache to expire

During migration:

# Step 2: Make the DNS change
# Update A record to new server IP

# Step 3: Keep the old server running
# Serve traffic on both old and new servers until propagation completes

After migration:

# Step 4: After 24-48 hours, raise TTL back to normal
# Set TTL to 3600 or higher

Checking Propagation Status

# Query specific resolvers to check propagation
dig @8.8.8.8 example.com A     # Google
dig @1.1.1.1 example.com A     # Cloudflare
dig @9.9.9.9 example.com A     # Quad9
dig @208.67.222.222 example.com A  # OpenDNS

Key Takeaways

  • TTL controls how long DNS records are cached — lower TTL means faster propagation but more queries to your nameserver.
  • Always lower TTL before making changes, not at the same time.
  • Keep old infrastructure running during the transition period.
  • Full global propagation typically takes 24-48 hours for high-TTL records.

另请参阅