brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Guide: AdGuard Home with Unbound: resolve DNS yourself instead of asking Cloudflare or your ISP

AdGuard Home with Unbound: resolve DNS yourself instead of asking Cloudflare or your ISP

Guide dns

10 steps 11 min read

For a long time my AdGuard Home forwarded everything to a big public resolver, which is a bit silly: I block trackers at home and then tell one company every site I visit. Unbound fixes that. It is a recursive resolver, so it does the lookup itself, starting at the root servers, and AdGuard Home keeps doing what it is good at: filtering, the query log and per-client rules. I run the combined AdGuard Home + Unbound container on my Unraid server and I would not go back to forwarding. This guide shows the combined image and the two-container route, how to wire them up, how to test it and where it bites.

Time
11 min
Steps
10
Updated
19 Nov 2026

You will learn

  • What recursive resolving means, and…
  • Pick a layout: one container or two
  • Check that your network lets Unbound…
  • Point AdGuard Home at Unbound
  • Tune Unbound and turn on DNSSEC

Step 1 of 10: What recursive resolving means, and what it costs

A forwarding setup is simple: your device asks AdGuard Home, AdGuard Home asks Cloudflare, Google, Quad9 or your ISP, and that resolver does the work. A recursive resolver does the work itself. For a name like example.nl it asks a root server who handles .nl, asks a .nl server who handles example.nl, and finally asks the nameserver of that domain for the address. The animation shows the trip and the cache that makes the second lookup instant.

What you gain: no single upstream sees your whole browsing history, and nobody else’s cache can serve you a poisoned answer. Unbound also validates DNSSEC itself, so a signed domain with broken signatures fails instead of being trusted, and with qname-minimisation (on by default in the current docs) a root server learns about .nl, not the exact name.

What you pay: the first lookup of an unknown name is slower, because several servers are asked in turn. Pi-hole’s guide says the first request to a TLD you have not visited can take up to a second. On privacy: the queries still travel unencrypted on port 53, so your ISP can still see them on the wire, and it still sees the IP addresses you connect to. Recursive resolving removes a middleman and hides nothing from your ISP. If the ISP watching DNS is your worry, encrypted upstreams (DoH or DoT) are a different trade-off.

Animation of one DNS lookup: client, AdGuard Home, Unbound, then root, TLD and authoritative server, with the answer cached at the end
Animation: one lookup travelling through AdGuard Home and Unbound

What you get and what you need

At the end, your devices are filtered by AdGuard Home and whatever passes is resolved by Unbound with DNSSEC validation, with no third-party resolver involved. You need a Docker host (an Unraid box, for me), a free LAN address, outbound port 53 over UDP and TCP, and access to your router or DHCP settings. The file contents below come from the Mainfrezzer image repository and Unbound’s current documentation, so check them against the version you run.

Step 2 of 10: Pick a layout: one container or two

The easy way is the combined image. On Unraid I use the community template AdGuard-Home-Unbound by Mainfrezzer, which pulls ghcr.io/mainfrezzer/adguardhome (there is also a Docker Hub copy as mainfrezzer/adguardhome). AdGuard Home and Unbound run inside one container, and Unbound only listens on the container’s loopback, 127.0.0.1:8053 (and [::1]:8053). Nothing outside the container can query it directly. The image’s docker run example, trimmed:

docker run --name adguardhome --restart unless-stopped \
  -v /my/own/workdir:/opt/adguardhome/work \
  -v /my/own/confdir:/opt/adguardhome/conf \
  -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 3000:3000/tcp \
  -d ghcr.io/mainfrezzer/adguardhome

Port 3000 is the first-run wizard, 80 the web interface afterwards; the image also publishes 67/68 (DHCP) and the encrypted-DNS ports, which you can skip. If you set PROVIDE_CONFIG=yes, the image writes a ready-made AdGuardHome.yaml on first start with the login admin and password adguardhome. Change that password right away. Both AdGuardHome.yaml and unbound.conf live in the config folder you mapped to /opt/adguardhome/conf. If there is no unbound.conf yet, the image copies a default one there on first start.

The alternative is two containers: the official adguard/adguardhome image plus an Unbound container next to it. Unbound then has to listen on a non-loopback address and refuse strangers (step 4).

Step 3 of 10: Check that your network lets Unbound reach the root servers

This is the step most guides skip, and it is the one that explains most ‘Unbound does not work’ stories. Some ISPs and routers quietly redirect outbound port 53 to their own resolver, and some CG-NAT setups drop DNS over TCP. Pi-hole’s docs have a neat test for it. From a machine on the same network, ask a root server directly, without recursion:

dig @198.41.0.4 . NS +norec +time=3
dig @198.41.0.4 . NS +norec +tcp +time=3
dig @198.41.0.4 version.bind CH TXT +time=3

A real root server answers with the aa flag set and without ra, the TCP query works, and the third command returns the text ATLAS. If you see ra but no aa, someone is answering for the root server and your recursive resolver will have a bad time. Fix that first (a router setting, a parental filter, a different network) before you blame the container.

Step 4 of 10: Point AdGuard Home at Unbound

AdGuard Home is basically a DNS proxy, so this is one field. In the web interface go to Settings, then DNS settings, and put Unbound in the Upstream DNS servers box (check the exact labels in your version). A plain address with a port is valid upstream syntax, according to AdGuard’s configuration docs. For the combined image that is:

127.0.0.1:8053

If you run two containers, use the address and port of the Unbound container instead, for example 192.168.1.x:5335 (5335 is the port Pi-hole’s guide uses to keep Unbound off 53; any free port works). Remove the public resolvers that were listed before, otherwise AdGuard Home will happily keep using them. Leave the Fallback DNS servers empty: a fallback is used when the upstreams do not respond, which would send queries to a third party exactly when Unbound has a bad moment. Bootstrap servers are only for hostname upstreams. Use the test button under the box and save.

In AdGuardHome.yaml this is dns.upstream_dns. The image’s file has enable_dnssec: false, which only controls the DO flag AdGuard Home sets upstream; validation happens in Unbound, so I leave it.

AdGuard Home DNS settings with 127.0.0.1:8053 as the only upstream DNS server
Settings, DNS settings in AdGuard Home: Unbound from the combined image as the only upstream.
Cheat sheet with the AdGuard Home upstream setting, the key unbound.conf lines and the dig test commands

Step 5 of 10: Tune Unbound and turn on DNSSEC

The combined image ships with sensible defaults: prefetch: yes, serve-expired: yes, a root hints file that it downloads on start and refreshes weekly, and cache-min-ttl: 300. Unbound’s docs warn that values above an hour or so can cause trouble, so I would not raise it. DNSSEC is off until you enable it. Set the environment variable DNSSEC_ENABLE=1 on the container (on Unraid it is the Enable DNSSEC setting under advanced). The start script then creates /etc/unbound/root.key with unbound-anchor. Then uncomment the trust anchor line in unbound.conf and restart the container:

server:
    auto-trust-anchor-file: "/etc/unbound/root.key"
    harden-glue: yes
    harden-dnssec-stripped: yes
    prefetch: yes
    cache-min-ttl: 300

From the Unbound manual: prefetch refreshes popular entries in the last tenth of their TTL for about ten percent more traffic; harden-dnssec-stripped makes a zone bogus if expected signed data is missing; auto-trust-anchor-file tracks the root key with RFC 5011 probes, so Unbound needs write access to it. Without native IPv6, set do-ip6: no (the default is yes).

For two containers, the difference is who may ask. Unbound answers only localhost by default and refuses the rest, so give it a port, an interface and a narrow allow rule:

server:
    interface: 0.0.0.0
    port: 5335
    access-control: 192.168.0.0/16 allow
    access-control: 172.16.0.0/12 allow
    hide-identity: yes
    hide-version: yes
    qname-minimisation: yes
    do-ip6: no

Run unbound-checkconf on the file before restarting; it points at the exact line when something is wrong. hide-identity and hide-version make those queries return REFUSED. Never publish this port to the internet, and never forward port 53 from your router to this machine.

Step 6 of 10: Tell your devices to use AdGuard Home

Nothing is filtered until clients ask AdGuard Home. AdGuard’s own guide says to open the router settings, find the DHCP/DNS section and enter the AdGuard Home address, and it adds that on some routers a custom DNS server cannot be set. That is common with many ISP routers: the box simply has no field for it. In the Netherlands, Ziggo documents a bridge mode for its modem, which lets you put your own router behind it and set DNS there. I could not verify the details per model, so check yours.

The other route, also from AdGuard’s docs, is to let AdGuard Home be the DHCP server and switch the router’s DHCP off, so the two never compete. The image publishes 67/68 for that. Only one DHCP server may run on a network, and the container needs its own LAN address for DHCP to work. The last resort is DNS per device, which works but you will forget one.

Step 7 of 10: Test it

From a laptop, ask AdGuard Home (not Unbound, which listens on loopback in the combined image):

dig example.org @192.168.1.x
dig fail01.dnssec.works @192.168.1.x
dig +ad dnssec.works @192.168.1.x

The first should return NOERROR with an address. The second is a domain with deliberately broken DNSSEC signatures, listed as a test domain on the BIND mailing list and used in Pi-hole’s docs; a validating setup answers SERVFAIL and no address. The third should return an address, and the ad flag in the flags line means Authentic Data; it is only shown when the answer is validated and the flag survives the trip, so treat SERVFAIL on the second one as the real proof. These are third-party test domains, so repeat the test before you conclude anything. Then open AdGuard Home’s query log: an entry’s details show the upstream and the time taken, and a second query for the same name should be faster.

Terminal output of dig for fail01.dnssec.works answering SERVFAIL and dig +ad dnssec.works answering NOERROR with the ad flag
The broken-signature domain gets SERVFAIL, the valid one NOERROR with the ad flag.
Terminal output of two dig queries for netbsd.org: the first takes 691 msec, the second 6 msec
The same name twice: 691 ms the first time, 6 ms from the cache.
AdGuard Home query log for netbsd.org with response details showing DNS server 127.0.0.1:8053, 686 ms and NOERROR
The query log details name 127.0.0.1:8053 as the DNS server. The later rows for the same name are cached answers.

Step 8 of 10: Troubleshooting

Everything times out. Run the root server test from step 2 first. If the answers carry ra, something intercepts port 53. If UDP works and TCP does not, large answers fail in odd ways.

Some sites resolve slowly or fail, others are fine. If IPv6 is not native, set do-ip6: no; Unbound’s docs say that trying a protocol the system does not support can cause failures when internal limits are reached.

A site that opened fine now says SERVFAIL. With DNSSEC on, a domain whose signatures expired or were misconfigured is rejected by design. Check it with a DNSSEC analyser such as DNSViz before disabling validation, and make sure the host clock is right; signatures have validity dates.

Unbound will not start with the trust anchor on. The file must exist and be writable by the Unbound user, and so must its directory, because Unbound writes a temporary file there. The combined image’s start script handles that.

Port 53 is already in use. Usually systemd-resolved on the host; bind to another address or give the container its own LAN address.

A device ignores AdGuard Home. Browsers and phones can use their own encrypted DNS (DoH or a Private DNS setting) and skip your DHCP-provided server. Turn that off on the device if you want the filtering to apply.

Self-hosted names do not resolve. Unbound looks for them on the public internet and gets NXDOMAIN. Add a domain-specific upstream in AdGuard Home, [/home.example/]192.168.1.x, or a DNS rewrite.

Step 9 of 10: My advice

Use the combined image unless you have a reason to split it, leave DNSSEC on, keep the fallback list empty and accept that the very first visit to a new site can be a bit slower. I would not stack AdGuard’s optimistic caching on top of Unbound’s serve-expired; two layers serving stale data make mistakes harder to see. And give the box a fixed address before you point the whole house at it, because when DNS is down, nothing looks like DNS being down.

Step 10 of 10: Where to go next

If you want your tailnet to use this resolver as well, my guide on Tailscale split DNS with AdGuard Home picks up where this one stops. A DNS container that quietly dies takes the whole house offline, so a healthcheck is cheap insurance: see the Docker Compose healthcheck guide.

Further reading

Link