Sub topic 13
Changing records and the propagation myth
This chapter assumes you know how a lookup travels from a stub resolver to a recursive resolver and then to the authoritative servers. It also assumes you know what a TTL is and how resolvers cache answers. If those are fuzzy, review the chapters on recursive resolvers and caching first.
Nothing is pushed
People say a DNS change "propagates" across the internet. That word suggests your new record is sent out to servers around the world, and that it spreads like a wave. DNS does not work this way.
When you edit a record, you change data on your authoritative servers. Nothing else happens. No server announces the change. Resolvers around the world learn about it only when they ask again, and they ask again only when their cached copy expires.
So the real model is expiry, not propagation:
- The authoritative servers switch to the new data at one moment (after any sync between your primary and secondary servers).
- Each resolver holds an old copy that expires on its own schedule.
- Each resolver fetches the new data the first time a client asks after its old copy expires.
Different resolvers cached the old answer at different times. Their copies expire at different times. That is why some users see the change immediately and others see it much later. The uneven result looks like spreading, but it is only independent timers running out.
The upper bound: the old TTL
The longest a well-behaved resolver can keep serving the old answer is the TTL that was on the record when it cached it. It is the old TTL that matters, not the new one.
Suppose a record has a TTL of 86400 seconds (24 hours). You change the record and also lower the TTL to 300. A resolver that cached the old record one minute before your change will keep it for another 23 hours and 59 minutes. The new TTL of 300 only applies to copies fetched after the change.
This leads to the main rule for planned changes: lower the TTL before you make the change, not at the same time.
A planned change, step by step
Say you are moving www.example.com from one server to another and the current TTL is 3600 seconds.
- Lower the TTL on the record to 300 seconds. Do this at least one old TTL (3600 seconds, here) before the move. Wait for that time to pass. After that, every resolver holds either nothing or a copy with a short remaining life.
- Change the record value to the new address.
- Verify against the authoritative servers directly, then against public resolvers.
- Keep the old server running and serving traffic for at least the old TTL after the change. Some clients will still reach it.
- When you are confident, raise the TTL back to a longer value, such as 3600.
The cost of a low TTL is more queries to your authoritative servers and slightly slower lookups for users, because fewer answers come from cache. That is why you raise it again afterward.
Verifying a change with dig
Check the authoritative servers first. They tell you what the world will eventually see. Find them with NS, then query one directly.
dig +short example.com NS
dig @ns1.example.com www.example.com A +noall +answer +norecurseIf the authoritative answer is already correct, any remaining wrong answers come from caches. Now check a public resolver and watch the TTL count down.
dig @8.8.8.8 www.example.com A +noall +answer
sleep 10
dig @8.8.8.8 www.example.com A +noall +answerThe number in the second column of each answer line is the remaining TTL. If the second query shows a smaller number than the first, you are looking at a cached copy. The value of that number is the longest time that resolver will keep serving the old data. If it shows a full TTL again, the resolver just refetched.
Note that large public resolvers are often several servers behind one address. Two queries a few seconds apart may reach different cache instances and show different TTLs or even different answers. This is normal and does not mean the change is "still spreading".
Where the delay really comes from
The TTL on the record is the main cause of delay, but it is not the only one. Check these when a change seems slower than expected.
| Source of delay | What happens | What to do |
|---|---|---|
| Old record TTL | Resolvers keep the cached answer until it expires | Lower the TTL ahead of time |
| Negative caching | If a name did not exist when someone looked it up, the "no such name" answer is cached for the SOA negative TTL (the last SOA field) | Create new names before anyone queries them, or keep the negative TTL low |
| Delegation (NS) changes | The parent zone's NS records and glue have their own TTLs, often 24 to 48 hours at the TLD | Plan NS changes far ahead and keep old name servers running |
| Secondary servers | Secondaries copy the zone from the primary using the SOA refresh timer and NOTIFY | Check that the SOA serial increased and that secondaries have it |
| Resolver behavior | Some resolvers enforce a minimum TTL or ignore low values | Do not rely on very low TTLs reaching every user |
| Application caches | Browsers, JVMs and operating systems keep their own DNS caches | Restart the application, or flush local caches while testing |
The serial number
If you run your own authoritative servers with a primary and secondaries, remember that secondaries only transfer a zone when the SOA serial number is higher than their copy. If you edit a record and forget to increase the serial, the primary may answer correctly while the secondaries keep the old data. Resolvers then get different answers depending on which server they ask. This is one of the most common causes of "it works for some people and not for others". Many providers increase the serial automatically, but check if you manage zone files by hand.
Compare the serial on each authoritative server:
for ns in $(dig +short example.com NS); do
echo "$ns: $(dig +short @$ns example.com SOA | awk '{print $3}')"
doneAll servers should print the same serial once the zone has synchronized.
Changing name servers is different
Changing A or MX records affects data inside your zone. Changing the NS records at the registrar changes the delegation held by the parent zone. The TLD servers, not you, publish that data, and its TTL is set by the registry. It is often 1 to 2 days and you cannot lower it.
During a move between DNS providers, do this to avoid an outage:
- Create a complete copy of the zone at the new provider and test it by querying the new servers directly.
- Change the delegation at the registrar.
- Leave the old provider's zone in place, with identical data, until the old NS TTL has passed.
Resolvers will use either set of name servers during the transition. If both serve the same data, nobody notices.
Negative caching and new names
A common surprise: you add a new name, such as staging.example.com, test it before the record exists, and see NXDOMAIN. You then create the record and it still fails for a while. The resolver cached the "does not exist" answer. Its lifetime is the lower of the SOA record's own TTL and the SOA minimum field (the last number, which this tutorial's zone file calls the negative caching TTL). In the sample zone that is 300 seconds. So the new name appears within five minutes.
Avoid the problem by creating a record before anyone queries the name, and by not probing names you have not created yet.
Common mistakes
- Changing the TTL and the value at the same moment, then expecting a fast cutover.
- Shutting down the old server as soon as the record changes. Clients with cached answers keep sending traffic there.
- Testing only with the default resolver. You see one cache, not the authoritative truth.
- Forgetting the SOA serial on a manually managed zone.
- Treating "propagation checker" websites as proof. They query a handful of resolvers at one moment. They show which of those caches have expired, nothing more.
- Assuming a very low TTL is honored everywhere. Some resolvers and some applications hold records longer.
Exercises
Exercise
The record app.example.com A 192.0.2.10 has a TTL of 7200. At 09:00 you change it to 192.0.2.20 and set the TTL to 60 in the same edit. A resolver cached the old record at 08:55. When will this resolver start returning the new address, and what should you have done to make the cutover faster?
Show answer
The resolver cached the old record with TTL 7200 at 08:55, so its copy expires at 10:55. It returns the old address until then and fetches the new one on the first client query after that. The new TTL of 60 does not affect copies cached earlier. To make the cutover fast, lower the TTL to 60 at least 7200 seconds (two hours) before changing the address, then change the address once the old long-TTL copies have expired.
Exercise
You updated a record. dig @ns1.example.com www.example.com A +norecurse shows the new address, but dig @ns2.example.com www.example.com A +norecurse shows the old one. Name the most likely cause and how you would confirm it.
Show answer
ns2 is a secondary that has not received the new zone, most likely because the SOA serial was not increased or the transfer has not happened yet. Confirm by querying the SOA from both servers (dig +short @ns1.example.com example.com SOA and the same for ns2) and comparing the serial numbers. If ns2 has a lower serial, increase the serial on the primary and trigger a transfer or wait for the refresh interval.