Unbound resolves DNS queries recursively and caches the answers. The default module configuration includes the validator. Configure a root trust anchor via auto-trust-anchor-file: so Unbound can validate DNSSEC chains back to the root. Built-in root hints let Unbound start resolution at the DNS root. On a Linux homelab host, install Unbound, confirm it has a writable root.key, and configure interfaces and access-control: in unbound.conf. If systemd-resolved already occupies the address and port Unbound needs, free port 53 on that address. Run unbound-checkconf and verify validation with unbound-host and dig.
Evidence and limits: This guide is compiled from NLnet Labs Unbound documentation, including its Ubuntu 22.04 LTS home resolver example, IANA root file documentation, and the ISC BIND 9 DNSSEC Guide (9.21.29-dev). These sources were checked on 2026-11-26. The guide is not based on hands-on testing. Default file paths can vary by operating system package.
Install Unbound
NLnet Labs recommends installing Unbound through your operating system package manager if you’re a first-time user. See the Unbound Installation guide. On Ubuntu, run these commands.
sudo apt update
sudo apt install unbound
The macOS Big Sur example installs Unbound with brew install unbound. Building from source requires the OpenSSL and Expat libraries and their header files.
The Ubuntu home resolver setup uses /etc/unbound/unbound.conf. The source installation example uses /usr/local/etc/unbound/unbound.conf. See the Unbound Configuration guide for the settings to put in that file.
Initialize and maintain the root trust anchor
The default validator needs a root trust anchor to verify chains of trust back to the root zone. auto-trust-anchor-file: tracks and updates keys automatically during normal operation using RFC 5011.
On Ubuntu 22.04 LTS, the Unbound package creates /var/lib/unbound/root.key. Before applying the sample configuration, open /etc/unbound/unbound.conf and follow the package’s existing configuration include to check the trust-anchor setting. If the include already sets auto-trust-anchor-file:, keep that setting and omit the sample line. If you need to add the setting on a host-only resolver, add the sample’s auto-trust-anchor-file: line under server: and keep the loopback listener. Wherever the example uses /var/lib/unbound/root.key, substitute the actual package anchor path if it differs.
If the file needs initialization or an update, use unbound-anchor before starting Unbound, as documented in the unbound-anchor(8) manual. Run it with -a to specify the file path and -v to print status details (without -v, unbound-anchor prints almost nothing and is silent on errors):
sudo -u unbound unbound-anchor -v -a "/var/lib/unbound/root.key"
If you maintain an explicit root hints file, pass -r /path/to/root.hints; otherwise unbound-anchor uses built-in root hints. If the key file is missing or empty, unbound-anchor writes a built-in root key. When an RFC 5011 update fails to bring the anchor up to date, it attempts an HTTPS update using root-anchors.xml and root-anchors.p7s under RFC 7958. By default, it verifies the download against icannbundle.pem and uses a built-in certificate if that file is absent or empty.
Pay attention to unbound-anchor exit codes when scripting startup checks:
- Exit code
1means the root anchor was updated using the certificate or the built-in root anchor was used. - Exit code
0means no update was needed, an update was possible via RFC 5011 tracking, or an error occurred.
Before moving on, confirm that Unbound can access and update the trust anchor:
- The account running Unbound can read and write
root.key. - The account can write to the directory containing
root.keyso Unbound can create a temporary file there. - If Unbound runs in a chroot, keep
root.keyinside it.
Configure recursive resolution, access control, and DNSSEC
By default, Unbound listens on localhost on port 53. Its access rules implicitly allow 127.0.0.0/8 and refuse other addresses. To serve a home network with DNSSEC validation and unbound-control enabled, use these settings in your main configuration file, such as /etc/unbound/unbound.conf. On Ubuntu, complete the local resolver handoff below before applying these settings.
server:
# Track the root trust anchor with RFC 5011
auto-trust-anchor-file: "/var/lib/unbound/root.key"
# Send as little information as possible to upstream servers
qname-minimisation: yes
# Listen on all IPv4 interfaces
interface: 0.0.0.0
# interface: ::0
# Permit IPv4 loopback and your local subnet
access-control: 127.0.0.0/8 allow
access-control: 192.168.0.0/16 allow
# access-control: 2001:db8::/64 allow
# Refuse id.server, hostname.bind, version.server, and version.bind
hide-identity: yes
hide-version: yes
remote-control:
# Enable management with unbound-control
control-enable: yes
Security warning. When listening on all IPv4 or IPv6 addresses, limit access-control: to loopback and your LAN subnets. Never run an open recursive resolver reachable from outside your network.
Additional configuration files can be loaded with the include: directive. If you prefer an externally maintained file, download the root hints file and point root-hints: to its path. The file lists the names and IP addresses of the root name servers. The download is on the IANA Root Files page.
Key unbound.conf defaults and options
The unbound.conf(5) manual lists these defaults.
| Directive | Published default | Effect |
|---|---|---|
interface: | Localhost | Sets listening addresses. Use a LAN IP or 0.0.0.0 to serve other hosts. |
port: | 53 | Listening port for DNS queries |
do-ip4:, do-ip6:, do-udp:, do-tcp: | yes | Enables IPv4, IPv6, UDP, and TCP query handling |
access-control: | refuse globally (127.0.0.0/8 allowed) | Controls client netblocks (allow, refuse, deny, allow_snoop) |
root-hints: | "" | Uses built-in root hints for the IN class when empty |
harden-glue: | yes | Trusts glue records only within the server’s authority |
harden-dnssec-stripped: | yes | Treats trust-anchored zones as bogus if DNSSEC data is missing |
harden-below-nxdomain: | yes | Uses a known DNSSEC-secure NXDOMAIN to return NXDOMAIN for names beneath it. NSEC3 with Opt-Out is insufficient. |
harden-referral-path: | no | Off by default; not an RFC standard and increases query load |
edns-buffer-size: | 1232 | Advertised UDP EDNS reassembly buffer size in bytes |
hide-identity:, hide-version: | no | Set yes to refuse id.server, hostname.bind, version.server, and version.bind queries |
Resolve the systemd-resolved port 53 conflict and point clients to Unbound
Install dig before running the queries below. It comes with BIND, as documented in the ISC BIND 9 DNSSEC Guide.
Before changing the Ubuntu resolver, query the running Unbound instance directly. See NLnet Labs’s Resolver for Home Networks guide.
dig example.com @127.0.0.1
Check for an answer and verify that the SERVER: line shows 127.0.0.1#53.
In this Ubuntu setup, systemd-resolved listens at 127.0.0.53 on port 53. To free the port for wildcard binding and route host queries to Unbound, edit /etc/systemd/resolved.conf with administrator privileges. Set these options under [Resolve].
[Resolve]
DNS=127.0.0.1
DNSSEC=yes
DNSStubListener=no
Replace /etc/resolv.conf with a link to the resolver file managed by systemd-resolved, then restart that service.
sudo ln -fs /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved
Verify that the host’s default DNS resolver now answers through Unbound.
dig example.com
Check for an answer and verify that the SERVER: line shows 127.0.0.1#53. If you’re serving the LAN, apply the sample configuration above to bind Unbound to 0.0.0.0, substituting your LAN subnet in access-control:. For host-only use, keep the loopback listener. If the existing configuration already has the trust anchor and you made no changes to unbound.conf, skip to DNSSEC verification.
Validate configuration and manage Unbound
Check your configuration file for syntax and other errors before starting or reloading the service.
unbound-checkconf /etc/unbound/unbound.conf
Per the unbound-checkconf(8) manual, unbound-checkconf exits with 0 when the file is valid and 1 on errors. Pass -q to suppress success messages, -o <option> to print the resolved value of one directive, or -f with -o to show full pathnames with chroot applied.
If the control connection uses TLS and needs credentials, generate the keys and self-signed certificates. These files are unbound_server.key, unbound_server.pem, unbound_control.key, and unbound_control.pem. A Unix control socket needs no certificate or key.
sudo -u unbound unbound-control-setup
Use the configuration path you checked in each unbound-control -c command below, including flush_negative. Pass the path explicitly whenever it differs from the compiled default.
After unbound-checkconf succeeds, stop the running daemon. If remote control was already enabled, use sudo unbound-control -c /etc/unbound/unbound.conf stop. If remote control was disabled and this is the host’s only Unbound instance, use sudo pkill -f unbound as shown in the home resolver guide.
Start Unbound with the checked configuration. A restart applies the listener changes. The unbound-control(8) manual documents that start launches the daemon directly, so it works even if remote control was previously disabled.
sudo unbound-control -c /etc/unbound/unbound.conf start
Once the daemon is running with remote control enabled, manage and inspect it with unbound-control.
sudo unbound-control -c /etc/unbound/unbound.conf status
sudo unbound-control -c /etc/unbound/unbound.conf stats_noreset
sudo unbound-control -c /etc/unbound/unbound.conf reload_keep_cache
unbound-control reload flushes the cache while rereading the configuration, whereas reload_keep_cache attempts to preserve RRset and message caches if thread counts and cache sizes have not changed. stats_noreset prints counters without zeroing them.
Verify recursive resolution and DNSSEC validation
If you’re setting up Unbound for your LAN, test from another device after the restart. Replace 192.168.0.2 with your resolver’s LAN IP.
dig example.com @192.168.0.2
Confirm that the query returns an answer and that the SERVER: line matches your Unbound host’s LAN IP. For LAN clients, wait until this check succeeds before configuring your router’s DHCP settings to advertise that IP as their DNS server.
For a separate validation check, use unbound-host -D to enable DNSSEC validation. It reads the root anchor from the program’s default anchor path, which must contain the anchor for this check. Add -v to print validation results and look for secure on the signed name ftp.isc.org..
unbound-host -D -v ftp.isc.org.
As described in the unbound-host(1) manual, unbound-host -v labels each answer as secure (validated successfully with a key), insecure (no security configured for the name), or bogus (validation failed). Do not pass -r during this check, because -r reads forwarders from /etc/resolv.conf and can break DNSSEC validation if those forwarders do not pass DNSSEC data.
Next, verify DNSSEC through the running daemon using dig with +dnssec against a signed domain.
dig @127.0.0.1 ftp.isc.org. A +dnssec
Look for status: NOERROR, the ad (Authenticated Data) flag in the response header, and accompanying RRSIG records.
When a domain returns SERVFAIL, run the two queries below with the failing domain in place of example.com. See the ISC BIND 9 DNSSEC Guide.
dig @127.0.0.1 example.com A
dig @127.0.0.1 example.com A +cd
With the configuration shown, the +cd (Checking Disabled) flag asks Unbound to skip validation for that query. Unbound ignores the flag if ignore-cd-flag: yes is set. If the normal query returns SERVFAIL while the +cd query succeeds, the failure is a DNSSEC validation error.
Troubleshoot DNSSEC validation failures
With the configuration shown, use these checks when a query returns SERVFAIL and succeeds with dig +cd.
- Re-check trust anchor permissions. Confirm the
unbounduser can write toroot.keyand its parent directory, and re-run theunbound-anchorcommand above with the configured anchor path if the file is missing or outdated. - Flush cached failures. With remote control enabled, run
sudo unbound-control -c /etc/unbound/unbound.conf flush_negativeafter fixing a configuration or upstream issue. This clears negative cache entries, includingSERVFAILresponses and bad DNSSEC key entries.
Consider the following alternatives only after confirming a validation problem and ruling out an attack. Restart the server to read changes to unbound.conf. See NLnet Labs’s Howto Turn Off DNSSEC.
- Affected domain only. Temporarily bypass a broken chain of trust with
domain-insecure: "example", replacingexamplewith the affected domain. Per the unbound.conf(5) manual, Unbound then ignores the DNSSEC chain of trust towards that domain, so a trust anchor above it cannot make it secure. If you set a trust anchor for the domain itself, that anchor overridesdomain-insecure:and the domain is secured. - Resolver-wide permissive mode. Keep validation checks enabled while allowing bogus replies with
val-permissive-mode: yes. - Resolver-wide validation off. Turn off the validator module completely with
module-config: "iterator".
Security warning. Permissive mode returns bogus answers to clients and can slow resolution. Setting module-config: "iterator" disables validation. Revert to strict validation as soon as troubleshooting is complete.
Browse the Homelab DNS Guide posts index.