Find cheap domain names for your website - namesilo.com
Namesilo Blog
Blog
DNS12 min

Negative Caching (NXDOMAIN) 101: Using NSEC & TTLs to Your Advantage

NS
NameSilo Staff

11/20/2025
Share
DNS resolvers spend considerable resources handling queries for records that do not exist. When a user mistypes a subdomain, when a service moves to a different hostname, or when automated systems probe for endpoints, the DNS infrastructure must respond with negative answers. Understanding how these negative responses are cached and authenticated can significantly improve your zone's performance and security posture.
Negative caching allows resolvers to remember that a particular query returned nothing, reducing repeated lookups for nonexistent records. The mechanism involves specific TTL values, DNSSEC-authenticated proof of nonexistence, and careful consideration of how different response types affect resolver behavior. For domain owners, tuning these parameters means finding the right balance between reducing query load and maintaining flexibility for zone changes.

NXDOMAIN vs NODATA: Understanding Negative Response Types

DNS negative responses come in two distinct forms. An NXDOMAIN response indicates that the queried domain name does not exist at all within the zone. When a resolver asks for blog.example.com and that name has never been configured, the authoritative server responds with RCODE 3 (NXDOMAIN), meaning "no such domain."
A NODATA response, by contrast, indicates that the domain name exists but has no records of the requested type. If mail.example.com exists with an A record but a resolver queries for its AAAA record, the server responds with RCODE 0 (NOERROR) but includes no answer records. The name itself is valid, just not for the requested record type.
This distinction matters because resolvers cache these responses differently and because the implications for your zone structure vary. An NXDOMAIN tells resolvers that nothing exists at or below that name, which can affect wildcard matching and subdomain queries. A NODATA response is more specific, indicating only that a particular record type is absent.
When you register a domain and begin adding DNS records, every name you create explicitly exists. Everything else returns NXDOMAIN. Understanding this boundary helps when troubleshooting propagation issues or when designing subdomain structures that may grow over time.

RFC 2308 and Negative TTL Mechanics

The caching behavior for negative responses is defined in RFC 2308, which established how resolvers should handle and store negative answers. When an authoritative server sends an NXDOMAIN or NODATA response, it includes the SOA record for the zone in the authority section of the DNS message. This SOA record contains a critical value: the minimum TTL field.
Historically, the SOA minimum field specified the minimum TTL for all records in the zone. RFC 2308 repurposed this field to define how long negative responses should be cached. When a resolver receives an NXDOMAIN response, it caches that negative answer for the duration specified in the SOA minimum field.
A typical SOA record includes several timing parameters:
example.com. 3600 IN SOA ns1.example.com. admin.example.com. (
    2024031501 ; serial
    7200       ; refresh
    3600       ; retry
    1209600    ; expire
    86400      ; minimum/negative TTL
)

In this example, the minimum value of 86400 seconds (24 hours) means that if a resolver queries for nonexistent.example.com and receives an NXDOMAIN, it will cache that negative response for 24 hours before querying again. During that period, any subsequent queries for the same nonexistent name will be answered from cache without contacting your authoritative servers.
The challenge is selecting an appropriate value. Set it too high, and legitimate new records you add to your zone will be invisible to resolvers that have cached negative answers. Set it too low, and your authoritative servers will handle excessive queries for common mistyped or scanned subdomains.

Tuning Negative TTL for Different Use Cases

The optimal negative TTL depends on your zone's characteristics and change frequency. For stable zones where new subdomains are rarely added, a negative TTL of 24 hours (86400 seconds) or even longer reduces unnecessary query traffic. If someone mistypes a subdomain, resolvers will remember that mistake and avoid repeatedly asking your servers about it.
For zones undergoing active development or frequent structural changes, shorter negative TTLs provide more flexibility. A value of one hour (3600 seconds) means that when you add a new subdomain, it becomes visible to most resolvers within an hour, even if those resolvers previously cached a negative response for that name.
Organizations launching new services or subdomains on specific schedules might temporarily reduce negative TTL in advance of the launch. If you plan to activate staging.example.com on a particular date, lowering the negative TTL a day beforehand ensures that when the record goes live, cached negative responses expire quickly.
Consider the patterns of invalid queries your zone receives. If you see sustained scanning or typosquatting attempts against predictable subdomain patterns, a longer negative TTL helps absorb that traffic. On the other hand, if your zone serves many legitimate users who occasionally mistype addresses, shorter negative TTLs mean they will notice corrections more quickly.

DNSSEC and Authenticated Denial of Existence

Without DNSSEC, a resolver must trust that negative responses actually come from the authoritative server. An attacker performing DNS spoofing could inject false NXDOMAIN responses, causing a denial of service by making legitimate records appear nonexistent. DNSSEC addresses this by providing cryptographic proof that a name truly does not exist.
DNSSEC accomplishes authenticated denial of existence through NSEC (Next Secure) or NSEC3 records. These records allow a zone to prove that no records exist between two names in the zone's sorted order. When a resolver queries for a nonexistent name, the server responds with an NSEC or NSEC3 record that demonstrates the gap where that name would appear if it existed.
NSEC records create a chain linking each name in the zone to the next name in canonical order. If your zone contains only www.example.com and mail.example.com, the NSEC record for www.example.com might indicate that the next name is mail.example.com. If a resolver queries for ftp.example.com, the server can return the NSEC record showing that nothing exists between example.com and mail.example.com, proving that ftp.example.com does not exist.
This approach works effectively but reveals your zone's structure. By walking the NSEC chain from one record to the next, anyone can enumerate all names in your zone. For public websites this typically does not matter, but for zones with sensitive internal subdomains or complex structures, the enumeration capability may be undesirable.

NSEC3 and Zone Enumeration Tradeoffs

NSEC3 was developed to prevent zone walking while still providing authenticated denial of existence. Instead of directly linking names in canonical order, NSEC3 hashes the domain names and links the hashes. This makes it computationally difficult to enumerate all names in a zone since an attacker would need to guess names and compute their hashes to determine if they exist.
An NSEC3 record covers a range of hashed names rather than plaintext names. When a resolver queries for a nonexistent name, the server computes the hash of that name and returns the NSEC3 record covering the hash range where that name would appear if it existed. The resolver can verify the proof without learning about other names in the zone.
However, NSEC3 comes with tradeoffs. It requires more computational resources on the authoritative server to generate responses, since each query for a nonexistent name requires hashing and NSEC3 record lookup. The resulting DNS responses are also larger, consuming more bandwidth and potentially pushing some responses over UDP size limits, forcing fallback to TCP.
For zones with numerous subdomains or with security requirements around subdomain privacy, NSEC3 provides meaningful protection against enumeration. For smaller zones or those where subdomain structure is already public, the operational complexity of NSEC3 may outweigh its benefits. Many high-traffic domains opt for NSEC due to its simpler implementation and lower computational overhead.
If you choose to implement DNSSEC with your SSL certificates to create a comprehensive security approach, evaluate whether your DNS infrastructure and authoritative servers support NSEC3 efficiently. Some managed DNS providers offer NSEC3 as a simple configuration option, while others may only support NSEC or require manual zone signing.

Wildcard Records and Negative Caching Interaction

Wildcard DNS records introduce complexity into negative caching behavior. A wildcard record like *.example.com matches any query for a subdomain that does not have a more specific record. When resolvers encounter wildcards, they must determine whether a query should match the wildcard or return NXDOMAIN.
If your zone contains a wildcard A record and no other subdomains, a query for random.example.com will match the wildcard and return an answer. This means the resolver receives a positive response, not a negative one, and caches it according to the TTL of the wildcard record itself.
However, if your zone contains both a wildcard and specific records, the behavior becomes more nuanced. A query for existing.example.com will match that specific record if it exists, ignoring the wildcard. A query for nonexistent.example.com will match the wildcard. The negative TTL only applies to names that neither match a specific record nor fall under the wildcard.
DNSSEC further complicates wildcard handling. To prove that a wildcard match is legitimate, the server must provide NSEC or NSEC3 records showing that no more specific record exists for the queried name. This requires the resolver to verify both that the wildcard exists and that nothing more specific overrides it.
From a practical perspective, zones using wildcards should carefully consider their negative TTL settings. If you add specific subdomains that override the wildcard, resolvers that previously matched the wildcard will not immediately see the new specific record. Instead, they will continue using their cached wildcard response until its TTL expires. This is separate from negative caching but can create similar propagation delays.

Cache Poisoning and Negative Response Security

Negative responses represent a potential attack vector in DNS cache poisoning scenarios. An attacker who can inject false NXDOMAIN responses into a resolver's cache can effectively deny service for legitimate domains. Without DNSSEC, resolvers have limited ability to verify the authenticity of negative responses.
The classical Kaminsky attack exploited this by sending both fake queries and fake responses to resolvers, attempting to poison the cache with malicious data. While modern resolvers implement various defenses like random port selection and query ID randomization, the fundamental challenge remains: unsigned negative responses require trust in the network path.
DNSSEC provides strong protection by requiring cryptographic signatures on all responses, including negative ones. A resolver validating DNSSEC signatures will reject any negative response that lacks proper NSEC or NSEC3 proof. This makes cache poisoning significantly harder, though not impossible if an attacker can compromise signing keys or the authoritative servers themselves.
For domain owners, enabling DNSSEC with properly signed negative responses provides assurance that resolvers will not accept false NXDOMAIN answers for your zone. This protection extends to email infrastructure, web services, and any other critical resources identified by DNS names.
When operating email services on custom domains, DNSSEC-validated negative responses prevent attackers from claiming that legitimate MX records do not exist, which could redirect mail or cause delivery failures. The authentication provided by NSEC or NSEC3 records ensures that resolvers trust negative answers as much as positive ones.

Resolver Behavior and Implementation Variations

Not all DNS resolvers implement negative caching identically. While RFC 2308 provides clear guidance, resolver implementations vary in how strictly they follow the specification and how they balance caching efficiency against zone change responsiveness.
Some aggressive resolvers may cache negative responses for longer than the specified TTL if they detect patterns of repeated queries for nonexistent names. This behavior, while not strictly compliant, helps protect resolvers from query floods targeting random subdomains. As a zone operator, you should be aware that some negative responses may persist in caches longer than your SOA minimum suggests.
Other resolvers implement negative TTL caps, refusing to cache negative responses for more than a certain maximum duration regardless of the SOA minimum value. This prevents zones from setting excessively long negative TTLs that might make new records effectively invisible for extended periods.
The combination of resolver behavior and negative caching creates interesting propagation dynamics. When you add a new record to your zone, resolvers with cached negative responses will not see it until their cache expires. This can create the appearance of inconsistent DNS behavior, where some users can resolve a newly added name while others cannot.
Planning for this propagation delay requires coordination between negative TTL values and change schedules. If you need a new record to be universally visible within one hour, your negative TTL must be no more than one hour, and you must wait at least that long after adding the record before relying on its availability.

Monitoring and Troubleshooting Negative Responses

Understanding how your zone's negative responses behave in practice requires monitoring query patterns and response codes. Authoritative server logs typically record NXDOMAIN and NODATA responses, allowing you to see which nonexistent names are being queried most frequently.
High volumes of NXDOMAIN responses might indicate several scenarios. Legitimate traffic may be mistyping subdomains, suggesting opportunities for better user communication or catch-all redirects. Automated scanners may be probing for common subdomain patterns like admin, dev, or test. Or, applications may be misconfigured with stale DNS names that no longer exist.
Tools like dig allow you to examine negative responses directly:
dig nonexistent.example.com

The response will show the RCODE (NXDOMAIN or NOERROR), the SOA record indicating the negative TTL, and any NSEC or NSEC3 records if DNSSEC is enabled. By examining these responses, you can verify that your zone is returning appropriate negative TTLs and authenticated denial of existence proofs.
For zones behind content delivery networks or managed DNS providers, check whether the provider allows you to customize the negative TTL. Some providers set this value at the account or zone level, while others may enforce a fixed value across all customers. Understanding your provider's policy helps you plan for propagation timing when making zone changes.

Practical Recommendations for Negative TTL Configuration

Start with a moderate negative TTL of 3600 seconds (one hour) for most zones. This value provides reasonable protection against repeated queries for nonexistent names while allowing new records to become visible relatively quickly after being added.
For stable production zones where changes are infrequent and planned well in advance, consider increasing the negative TTL to 86400 seconds (24 hours). This reduces query load on your authoritative servers and helps absorb traffic from scanners or bots probing for common subdomains.
For development or staging zones where new subdomains appear frequently, use shorter negative TTLs of 300 to 900 seconds (5 to 15 minutes). The increased query traffic is usually manageable for zones with lighter overall load, and the faster propagation of new records improves developer experience.
When planning to add new records to your zone, temporarily reduce the negative TTL before making changes. If your normal negative TTL is 24 hours but you are launching a new service tomorrow, reduce it to one hour starting today. After the new records are added and fully propagated, you can gradually increase the negative TTL back to its normal value.
Document your negative TTL strategy as part of your DNS management procedures. Team members making zone changes should understand how long cached negative responses will persist and plan accordingly. This is particularly important for time-sensitive launches or when coordinating DNS changes with application deployments.

The Bigger Picture of DNS Efficiency

Negative caching represents one component of overall DNS efficiency. When combined with appropriate positive TTLs for existing records, thoughtful zone structure, and proper DNSSEC implementation, negative caching helps create a resilient and performant DNS infrastructure.
The key is recognizing that DNS caching operates on both positive and negative answers, and both require deliberate configuration. Many zone operators carefully tune TTLs for their published records but overlook the SOA minimum field that controls negative caching. This oversight can lead to unexpected propagation delays or excessive query load from repeated lookups of nonexistent names.
As your zone grows and evolves, periodically review your negative TTL settings in light of actual query patterns and change frequency. What worked for a small zone with a handful of subdomains may need adjustment as you add services, launch new initiatives, or migrate infrastructure.
Understanding negative caching also helps when troubleshooting DNS issues. If users report that a newly added record is not resolving, checking for cached negative responses should be part of your diagnostic process. Similarly, if authoritative servers show unexpected query patterns, examining which nonexistent names are being queried most frequently can reveal configuration issues or security concerns.
Negative caching may seem like an obscure technical detail, but it has real operational impact. By understanding NXDOMAIN responses, negative TTLs, and authenticated denial of existence, you gain another tool for optimizing your DNS infrastructure and ensuring that changes propagate predictably across the internet's resolver ecosystem.
ns
NameSilo StaffThe NameSilo staff of writers worked together on this post. It was a combination of efforts from our passionate writers that produce content to educate and provide insights for all our readers.
More articleswritten by NameSilo
Jump to
Smiling person asking you to sign up for newsletter
Namesilo Blog
Crafted with Care by Professionals

Millions of customers rely on our domains and web hosting to get their ideas online. We know what we do and like to share them with you.

This newsletter may contain advertising, deals, or affiliate links. Subscribing to a newsletter indicates your consent to our Terms of Use and Privacy Policy. You may unsubscribe from the newsletters at any time.