Sub topic 13
Validating DNSSEC on your resolver
This chapter assumes you can run Unbound or BIND as a recursive resolver, as covered in the earlier chapters. You should also be comfortable reading dig output and checking system time with timedatectl.
What validation does
DNS answers travel in plain form and a resolver cannot normally tell a genuine answer from a forged one. DNSSEC (DNS Security Extensions) adds digital signatures to DNS data. A validating resolver checks those signatures and discards answers that fail.
DNSSEC does not encrypt anything, and it does not hide your queries from observers. It proves only that the data came from the zone's owner and was not changed on the way.
Validation happens on the resolver. Authoritative servers publish signatures, and signing a zone is a separate task from the one in this chapter. Here you turn validation on for the clients of your resolver.
The chain of trust
A signed zone publishes these record types:
| Record | Purpose |
|---|---|
| RRSIG | A signature over one set of records, such as all A records for a name |
| DNSKEY | The public keys of the zone, used to check RRSIG records |
| DS | A hash of a child zone's key, stored in the parent zone |
| NSEC / NSEC3 | Signed proof that a name or record type does not exist |
The resolver trusts one starting point, the root zone's key. This is the trust anchor. From there each parent vouches for its child through a DS record.
If every link checks out, the resolver marks the answer secure and sets the ad (authenticated data) flag in its reply. If a zone has no DS record in its parent, the zone is insecure: it is unsigned on purpose, and the resolver accepts the answer without the ad flag. If a signature is wrong, expired, or missing where a DS says it must exist, the answer is bogus. The resolver then returns SERVFAIL.
The difference between insecure and bogus is the core of the design. A zone that was never signed still works. A zone that claims to be signed but fails the checks is refused.
Enabling validation in Unbound
Unbound has the validator module on by default in most builds. The only item you must provide is the trust anchor. The Debian and Ubuntu packages create it for you. Otherwise you can create it yourself:
sudo unbound-anchor -a /var/lib/unbound/root.key
sudo chown unbound:unbound /var/lib/unbound/root.keyThen reference it in the server: block you already have:
server:
auto-trust-anchor-file: "/var/lib/unbound/root.key"
harden-dnssec-stripped: yes
harden-below-nxdomain: yes
val-log-level: 1auto-trust-anchor-filekeeps the root key current. Unbound follows the RFC 5011 rollover process and rewrites the file itself, so theunbounduser must be able to write to it.harden-dnssec-stripped: yesrejects answers that lack signatures for a zone known to be signed. This blocks downgrade attacks, and it is the default in current releases. Setting it explicitly documents your intent.val-log-level: 1logs a line for each validation failure. Level 2 adds the reason, which helps with troubleshooting.
Some distributions instead ship a root-auto-trust-anchor-file.conf snippet that sets the same option. Check /etc/unbound/unbound.conf.d/ first so you do not define the anchor twice.
Enabling validation in BIND
BIND validates by default in current releases. The setting is dnssec-validation auto, which uses a built-in copy of the root trust anchor and manages rollovers for you.
options {
directory "/var/cache/bind";
recursion yes;
allow-recursion { trusted; };
dnssec-validation auto;
};Avoid dnssec-validation yes unless you have configured a trust anchor yourself with trust-anchors. Without an anchor, yes validates nothing useful. Do not set no on a resolver that serves real clients.
Apply and check the change:
sudo named-checkconf
sudo rndc reconfig
sudo rndc validation statusBIND also ships delv, a debugging tool that performs its own validation and reports which step failed. It is useful when you cannot tell whether the resolver or the zone is at fault.
Testing validation
Query a signed name through your resolver and look at the flags:
dig @127.0.0.1 example.org A +dnssecIn the header, flags: qr rd ra ad shows that the answer validated. If ad is missing, the name is unsigned or your resolver is not validating. Run the same query against a zone you know to be unsigned. It should return an answer without ad, and that confirms the resolver is distinguishing the cases.
To prove that bad signatures are rejected, query a deliberately broken test zone. Public test zones for this purpose come and go, so search for a current one. A bogus name should return SERVFAIL through your resolver, while a non-validating public resolver returns an answer. Then check that SERVFAIL is caused by validation:
dig @127.0.0.1 broken.example.net A
dig @127.0.0.1 broken.example.net A +cdThe +cd option sets the Checking Disabled flag, which tells the resolver to skip validation for that query. If the plain query gives SERVFAIL and the +cd query gives an answer, the cause is a DNSSEC problem and not a network fault.
Unbound also provides a direct check:
unbound-host -C /etc/unbound/unbound.conf -v example.orgThe output says (secure), (insecure) or (BOGUS) for each answer.
Common failures
Wrong system clock. RRSIG records have inception and expiration times. A server whose clock is hours or days off rejects valid signatures, and every signed domain fails at once. Run a time-sync service such as chrony and check timedatectl before anything else. This is the most frequent cause on virtual machines that were suspended or restored from a snapshot.
Large responses are dropped. DNSSEC answers are bigger than plain ones. If a firewall blocks fragmented UDP or blocks TCP port 53, validation fails intermittently and only for some names. Allow TCP and UDP on port 53 in both directions for the resolver's own outgoing queries.
Middleboxes that strip or alter records. Some forwarders, hotel networks and old routers remove DNSSEC records. If you forward to an upstream server, that upstream must pass DNSSEC data along. Your resolver still validates the result itself. A stripping upstream causes SERVFAIL, not a silent downgrade.
A broken zone at the source. A domain owner can let signatures expire or publish a DS that does not match the zone's key. Your resolver is working correctly when it refuses these answers. Confirm with +cd, then contact the zone's operator. Avoid disabling validation globally to reach one site. If you must override, Unbound offers domain-insecure: "example.net", and BIND offers validate-except with a list of names. Both limit the exception to one zone.
Negative trust anchors and stale anchors. An old, unmanaged anchor file stops matching after a root key rollover. This is why the managed options, auto-trust-anchor-file and dnssec-validation auto, are the right defaults.
Forwarding and validation
If your resolver forwards to another server, keep two things in mind. Your resolver can validate only if the upstream returns the signature records, which means the upstream must support DNSSEC. Also, the ad flag in an upstream's reply is not proof unless you trust the link to that server. A validating resolver does its own checking and ignores the upstream's flag.
Exercise
A client queries your validating resolver for a name and gets SERVFAIL. The same query with +cd returns an A record. A resolver at a different site returns the record normally, and your system clock is correct. What are the likely causes, and what is the narrowest fix?
Show answer
The +cd result shows that the failure comes from DNSSEC validation, not from reaching the server. The most likely causes are an expired signature or a DS and DNSKEY mismatch in the zone, or a trust anchor on your resolver that is stale. The other site probably does not validate, or it has the zone's valid data cached. Check unbound-host -v or delv to see which step fails, and set val-log-level: 2 in Unbound to log the reason. If the zone itself is broken, ask its operator to fix it. As a temporary measure, add a scoped exception with domain-insecure in Unbound or validate-except in BIND for that one domain, not a global disable.