NSEC record

Also known as: NSEC3

On this page 7

An NSEC record (Next Secure record) is a DNSSEC resource record that provides authenticated denial of existence: it proves, with a cryptographic signature, that a queried name or record type does not exist in a zone. Among the DNS records used on the Internet, it is the one that lets a validating resolver trust a negative answer such as NXDOMAIN or NODATA instead of accepting it blindly.

Each NSEC record names the next existing owner name in the zone and lists the record types present at its own name. Because the whole set of NSEC records forms a closed chain, the gap between two names proves that nothing lies between them. Its hashed successor, NSEC3, solves the main weakness of this design, which is that the chain can be walked to list every name in the zone.

How an NSEC record proves that a name does not exist

An NSEC record proves nonexistence by covering an interval in canonical order. DNSSEC sorts all owner names of a zone in a defined canonical ordering (label by label, from the rightmost label, case-insensitive). Each NSEC record at name A points to the next name B, so the signed statement reads: no name exists between A and B.

When a resolver asks for a name that falls inside such a gap, the authoritative server returns the covering NSEC record together with its RRSIG signature. The resolver checks the signature against the zone’s DNSKEY record and confirms that the queried name sorts between the two names. The last NSEC record in the zone points back to the zone apex, which closes the chain.

The record also carries a type bitmap, a compact list of the record types that exist at its owner name. This field proves NODATA responses: if a client asks for an AAAA record at a name whose bitmap lists only A, RRSIG and NSEC, the absence of AAAA is signed and verifiable.

The table below lists the fields of an NSEC record as defined in RFC 4034.

FieldContentPurpose
Owner nameAn existing name in the zoneStart of the covered interval
Next domain nameThe following name in canonical orderEnd of the covered interval
Type bitmapRecord types present at the owner nameProves which types exist
TTLUsually the SOA minimum TTLControls negative caching time
Fields of an NSEC record

Negative answers that rely on NSEC records

DNSSEC needs NSEC records because negative answers cannot be signed directly. A server cannot pre-sign an answer for every possible nonexistent name, so it signs the existing intervals instead, and those proofs apply to any name that falls inside them.

Different negative situations require different combinations of NSEC records, as the following table shows.

SituationRecords returnedWhat the resolver verifies
NXDOMAINNSEC covering the name, NSEC covering the wildcardNeither the name nor a matching wildcard exists
NODATANSEC at the queried nameThe name exists but the type is absent from the bitmap
Wildcard expansionNSEC covering the original nameThe answer was synthesized from a wildcard
Insecure delegationNSEC at the delegation pointNo DS record exists for the child zone
Proofs built from NSEC records

The insecure delegation proof matters for operators: when a parent zone shows an NS record but no DS record in the NSEC bitmap, the resolver knows the child zone is intentionally unsigned and treats its answers as insecure rather than bogus.

NSEC compared with NSEC3 and compact denial

The main weakness of plain NSEC is zone walking, also called zone enumeration. Because each record reveals the next real name, anyone can follow the chain from the apex and list every name in the zone, which defeats the protection that disabling zone transfers normally provides.

NSEC3, defined in RFC 5155, replaces owner names with salted SHA-1 hashes and links the hashes in hash order. An attacker can still collect the hashes, but must run an offline dictionary attack to recover names. NSEC3 also offers the opt-out flag, which lets large delegation-heavy zones skip unsigned delegations. A third approach, often called compact denial of existence or black lies, generates a minimal NSEC record on the fly for each query.

PropertyNSECNSEC3Compact denial
Name exposureNames readable in clear textHashed names, crackable offlineNo real neighbors revealed
Signing modeOffline or onlineOffline or onlineOnline signing required
Resolver costLowHigher, hashing per queryLow
Aggressive cachingFully supportedSupported, less effective with opt-outNot useful
Typical usePublic zones, root zoneTLDs and sensitive zonesLarge DNS hosting platforms
Comparison of denial-of-existence methods

Since RFC 9276, operators who choose NSEC3 are advised to use zero additional iterations and an empty salt, because extra iterations add resolver cost without meaningful protection. Many resolvers treat high iteration counts as insecure.

Aggressive negative caching with NSEC

NSEC records enable aggressive use of DNSSEC-validated cache, standardized in RFC 8198. A validating resolver that has cached a signed NSEC record can answer any query falling into the same interval without contacting the authoritative server, because the proof already covers it.

This behavior reduces load from random subdomain attacks, also known as water torture attacks, where attackers send queries for random nonexistent names. It also reduces junk traffic to the root zone, which uses NSEC rather than NSEC3 partly for this reason.

Deploying NSEC records and avoiding common faults

Operators rarely write NSEC records by hand: the signing software generates the chain whenever the zone is signed, and must rebuild it whenever a name is added or removed. The choice between NSEC and NSEC3 is therefore a zone signing policy decision, not a manual record edit.

The following table maps frequent symptoms to their causes and fixes.

SymptomLikely causeFix
SERVFAIL on missing namesBroken or stale NSEC chainRe-sign the zone after every change
Valid names reported missingChain not updated after adding a nameUse automatic incremental signing
Full zone listed by outsidersPlain NSEC on a sensitive zoneSwitch to NSEC3 or compact denial
Validation fails for wildcard answersMissing wildcard proof in responsesCheck server software and zone signer
Common NSEC problems
  • Do not treat NSEC as secrecy: DNS names should never be relied on as hidden information.
  • Keep the NSEC TTL aligned with the negative caching TTL to avoid long-lived stale proofs.
  • Test with validation tools such as dig +dnssec or delv after every signing policy change.

Put simply

Imagine a printed, alphabetical guest list where every line says who comes next. If someone asks whether a certain person is invited, the host points to two neighboring lines and shows that the name would sit between them, yet nobody is written there. The list is stamped and signed, so the answer cannot be faked.

An NSEC record does exactly this for DNS. It turns an empty answer into a signed proof, so a resolver can trust that a name or record truly does not exist. The trade-off is that the same chain lets anyone read the whole list from top to bottom.

In practice

A university IT team signs its public zone with DNSSEC using plain NSEC. A validating resolver at a student residence receives a query for a mistyped name, libary.example.edu. The authoritative server returns NXDOMAIN with the NSEC record at lab.example.edu pointing to library.example.edu, plus the NSEC record that rules out a wildcard. The resolver verifies both signatures and confirms the negative answer, and it caches the proof for 3,600 seconds.

During an exam week, a misconfigured script floods the resolver with thousands of random lookups under the same zone. Thanks to aggressive negative caching, the resolver answers most of them from the cached NSEC intervals, and traffic to the authoritative servers falls sharply. The team later moves its internal staff subdomain to NSEC3 with zero iterations, because that part of the zone contains host names that should not be easy to enumerate.