A classic that bites everybody once. You add new.example.com to your zone, query it, and it still says NXDOMAIN. You wait ten minutes. Still NXDOMAIN. The zone is correct, the authoritative server answers properly. What is going on?
Negative caching. An NXDOMAIN answer is cached too (RFC 2308). If someone, or something, asked for the name before you created it, the resolver remembered "this does not exist" and will keep saying so until the negative TTL runs out.
How long? It is the smaller of the TTL of the SOA record and the SOA minimum field. You can see it:
$ dig +noall +authority new.example.com @192.0.2.53
example.com. 3600 IN SOA ns1.example.com. hostmaster.example.com. 2025070301 7200 900 1209600 3600
Here the TTL is 3600 and the last number (the negative-caching TTL) is 3600, so up to an hour of "does not exist".
Practical advice:
- Keep the SOA negative TTL modest (300 to 900 seconds is common) if you create names often.
- Before creating a name, do not "just check that it is free" with a query through the resolver everybody uses. Ask the authoritative server directly with
dig @ns1 .... - To test from a clean slate, flush the cache of your own resolver, not the world's.
A name that is not there yet, remembered as never there. The cache has good manners.