Homelab · Networking

Unbound: Recursive DNS for Your Network

Every DNS setup in this site’s guides so far forwards your lookups to somebody else’s resolver — Cloudflare, Quad9, Google — and trusts them with the full list of names your household asks about. Unbound removes that somebody. It is a recursive resolver: given a name, it walks the DNS hierarchy itself, asking the root servers, then the top-level domain servers, then the site’s own servers, and validates the answers cryptographically on the way. Run it behind the AdGuard Home or Pi-hole you already have, and the filtering you like stays while the forwarding you never chose goes away.

Published Nov 21, 2026

Forwarding versus resolving: the difference that matters

When your current setup forwards, one upstream company receives every lookup from every device in the house, in clear sequence, forever. That company may have an excellent privacy policy, but the arrangement is still a single observer with a complete record. Recursive resolution changes the shape of the traffic. Unbound asks the root servers only which servers handle .com, asks those servers only which servers handle a given domain, and asks those servers for the record itself — a technique called QNAME minimization means each level hears only the part of the question it needs. No single server sees your whole query, and no single company sees your household’s pattern. The answers are also checked rather than trusted: Unbound performs DNSSEC validation, verifying the chain of signatures from the root down, so a forged answer is rejected instead of served.

The trade you make is speed and simplicity, in small amounts. A forwarded lookup to a giant anycast resolver is often answered from a warm cache in single-digit milliseconds; a cold recursive lookup walks three levels and takes longer, once — after which Unbound’s own cache answers instantly for every other device in the house. In practice a household resolver’s cache hit rate climbs quickly and the difference disappears into noise, but the first lookup of an obscure name on a cold cache will feel slower, because it is. What you are buying with those milliseconds is the removal of a third party from every name your home resolves.

Where Unbound sits in the stack you already have

Unbound is not a replacement for AdGuard Home or Pi-hole, and this guide does not ask you to give either up. The layers divide cleanly: your devices keep asking AdGuard Home or Pi-hole, which keeps doing the jobs it is good at — blocklists, per-client rules, a readable query log, a friendly dashboard. The only change is its upstream. Instead of forwarding to a public resolver, it forwards to Unbound, conventionally on port 5335 on the same host or a nearby container, and Unbound does the resolving. The AdGuard Home vs Pi-hole comparison covers the front layer; this guide is about what sits behind it. Everything user-facing stays identical — the family notices nothing, which is the correct outcome for infrastructure.

The image question, settled

One confusion follows Unbound’s Docker story around the internet, so let us settle it: the standard community image is maintained by Matthew Vance, and “MVance” and “MatthewVance” are the same person and the same project — mvance/unbound is his Docker Hub name, MatthewVance is his GitHub name, and the repository is MatthewVance/unbound-docker. There are not two competing standard images to choose between. The image bundles Unbound with a sensible default configuration at /opt/unbound/etc/unbound/unbound.conf, expects to run as a dedicated resolver for a local network, and is the image this guide’s setup follows. Unbound itself is NLnet Labs’ project, the same team behind the authoritative server NSD, and it is also built into routers and firewalls — OPNsense ships it as its resolver — which is a fair sign of how unglamorous and settled this software is.

The configuration that matters

A recursive resolver for a home network needs a short list of deliberate settings. It should listen on the address and port your filtering layer points at — 5335 is the convention precisely because 53 is already taken by the layer in front. Access control should admit your LAN ranges and refuse the rest of the world: an open resolver reachable from the internet is an abuse magnet and a genuine menace, and Unbound’s defaults need your ranges stated rather than assumed. Caching with prefetch enabled keeps popular names warm by refreshing them just before they expire, and serving slightly expired answers while a refresh happens in the background smooths over slow authoritative servers. None of this is exotic; the image’s shipped configuration is close, and the changes are a handful of lines.

The one setting that is not optional, and the one this guide exists partly to warn about, is the DNSSEC trust anchor. Validation starts from the root zone’s key, and that key changes over time. The mechanism that tracks it is RFC 5011 automatic updates, configured with auto-trust-anchor-file — and the file it points at must live on a writable, persistent path, seeded once with unbound-anchor and then maintained by Unbound itself. Point it at the image’s persistent variable directory or a mounted volume you control. Two supporting details matter more than they sound: keep the root hints file reasonably fresh (a refresh roughly every six months is the usual advice), and keep the host’s clock correct with NTP, because signature validation is time arithmetic and a badly wrong clock fails it.

The classic failure, and why it fails that way

Every Unbound-in-Docker troubleshooting thread contains the same story. The container starts, works beautifully for weeks, and then one day every lookup returns SERVFAIL and the whole house is offline in the only way that matters. The cause, almost every time, is the trust anchor: the anchor file sat on a read-only mount or an ephemeral container layer, the root key rolled, Unbound could not update its copy, and validation began failing — so it refused to serve answers it could not verify. That refusal is the correct behavior. A validator that serves unvalidated answers when its key goes stale is not validating; it is decorating. The fix is the configuration above: anchor file on writable persistent storage, seeded properly, with the container’s data treated as state worth keeping rather than a cache to be discarded on rebuild. If you take one sentence from this guide, take that one, because it is the difference between a resolver that runs for years and one that ambushes you quarterly.

Checking it works, and living with it

Verification is quick. Query your Unbound directly for a name in a DNSSEC-signed zone and confirm the answer carries the authenticated-data flag; then query a deliberately bogus signed name — the test zones maintained for exactly this purpose — and confirm you get SERVFAIL, because a resolver that validates must fail that test on purpose. Then watch the front layer’s dashboard: queries flow, the upstream column shows your own resolver, and cache hits accumulate. Day to day there is nothing to do. Unbound has no blocklists to curate and no dashboard to admire; it logs, it caches, it validates. Update the container on your normal cadence, glance at the root hints twice a year, and the recursive layer joins the best category of home infrastructure: the kind you forget is there, doing a job you chose deliberately, exactly the way you chose it.

What recursive resolution does not do

Precision about privacy matters here, because the recursive pitch is easy to overstate. Moving from forwarding to recursion removes the aggregator — the single company holding your household’s complete lookup history. It does not make your queries invisible. The authoritative servers for each domain still see a query arriving from your home IP address; they simply see only the queries for their own domains, in isolation, without the surrounding pattern that makes a lookup history revealing. Your provider can also observe unencrypted DNS traffic in transit, which is a property of DNS itself rather than of either design; encrypting the path between your devices and your resolver is a separate, local concern, and the walk from resolver to authoritative servers is unencrypted by design of the current global system. The accurate claim is the one worth making: recursion shrinks the number of parties who can build a profile of your home from DNS to approximately none, and it puts the validity of every answer under cryptographic check. For a privacy-motivated change, that is a strong result stated at its true size.

It is also worth naming what stays the same, because households fear the wrong breakage. Your filtering layer still blocks what it blocked; a blocked name never reaches Unbound at all. Your local names — the NAS, the printer, the internal services your router or AdGuard instance resolves — are answered by the layers that own them and are never sent out for recursion. And if Unbound itself stops, the failure is total and obvious rather than silent and partial, which is the failure shape you want from infrastructure: the fix is a container restart, and the diagnosis takes one glance at which layer stopped answering.

Official documentation and references

Frequently asked questions

Do I still need AdGuard Home or Pi-hole with Unbound?

Yes, if you want filtering — and most readers do. Unbound resolves and validates; it does not maintain blocklists, per-client rules, or a family-friendly dashboard. The standard stack is devices to AdGuard Home or Pi-hole for filtering, then to Unbound on port 5335 for resolution. Each layer does the job it is good at.

Why port 5335?

Pure convention, born of necessity: port 53 on the host is already spoken for by the filtering layer in front. Unbound conventionally listens on 5335 so both can live on the same machine, and the front layer is configured with 127.0.0.1#5335 (or the container address) as its only upstream.

Everything suddenly returns SERVFAIL. What happened?

Almost always the DNSSEC trust anchor. If the anchor file is on a read-only or non-persistent path, Unbound cannot follow a root key roll, validation fails, and it correctly refuses to serve unverifiable answers. Put auto-trust-anchor-file on writable persistent storage, seed it with unbound-anchor, and check the host clock while you are there.

Is recursive resolution slower than forwarding?

A cold lookup is slower — Unbound walks the root, the top-level domain, and the site’s own servers instead of asking one warm cache. But it caches every answer, so subsequent lookups from any device in the house are instant. In a household, the cache warms quickly and the practical difference is a few milliseconds on first visits to obscure names.

Can I run Unbound without Docker?

Yes. Unbound is a standard package in most Linux distributions and is the built-in resolver in OPNsense, among others. The configuration principles in this guide — private ranges only, RFC 5011 anchor on persistent storage, sane clocks — apply identically; only the file locations move.

Related guides