Mad World #Save_GAZA: Free Palestine  

Search

Pi-hole + Unbound in Docker: Your Own Recursive DNS Server, With Production Settings (2026)

Pi-hole + Unbound in Docker: Your Own Recursive DNS Server, With Production Settings (2026)

Pi-hole blocks ads for your whole home, but it still sends every other name to a public DNS service such as Google or Cloudflare, so one company sees every site your home visits. Unbound removes that middleman. It is a recursive DNS server: it finds each answer itself, starting at the root servers of the internet, and checks the DNSSEC signatures on the way. This guide adds Unbound to Pi-hole in Docker Compose with the production settings we tested one by one, shows the startup trap that can leave a whole network without DNS, and gives real numbers for speed and memory.

Tested on 25 November 2026: Unbound 1.26.2 (Docker image klutchell/unbound:1.26.2) and Pi-hole Docker tag 2026.11.0 (FTL v6.9), in Docker 29.10.1 with Docker Compose v5.8.0, on an Ubuntu 26.04 home server at 192.168.1.50, asked by a laptop on the same network (192.168.1.21). Every command, output and screenshot below comes from that lab.

Quick answer: Pi-hole + Unbound in five steps

In plain words: when a device asks for the address of www.example.org, Pi-hole normally passes the question to a big public DNS service. With Unbound, your own server asks a root server which servers handle .org, asks one of those which servers handle example.org, and asks those for the address. No single company gets your full list of names, and every signed answer is checked with DNSSEC, the signatures that prove an answer was not changed on the way.

  1. Check that your server reaches the root servers on port 53 over UDP and TCP: dig @198.41.0.4 . NS +norec must show the aa flag.
  2. Write a small Unbound settings file, unbound/pi-hole.conf, next to your Pi-hole compose.yaml.
  3. Add an unbound service to the compose file with the image klutchell/unbound:1.26.2, a fixed address on the Docker network (172.30.53.53) and a health check.
  4. Point Pi-hole at that address, not at the name unbound: FTLCONF_dns_upstreams: 172.30.53.53. With the name, one restart in the wrong order left our whole network without DNS.
  5. Run docker compose up -d and test: dnssec.works must answer with the ad flag, and fail01.dnssec.works must fail with SERVFAIL.

The price: a name nobody in your home has asked for yet takes longer. In our tests, 20 new names took 11.2 to 14.9 seconds through Unbound (0.56 to 0.74 seconds each), against about 1.1 seconds straight from Google. A name already in the cache answered in 0 ms.

Pi-hole Query Log: www.isc.org asked by laptop.home.arpa, status Forwarded, reply from 172.30.53.53#53, DNSSEC status SECURE
The result: Pi-hole's Query Log for a name nobody had asked before. 1: answered by Unbound (172.30.53.53). 2: signatures checked: SECURE.

Five words you will meet in this guide:

  • Recursive DNS server (or recursive resolver): a server that finds answers itself by asking the servers in charge of each part of a name. Unbound is one.
  • Root servers: the 13 server groups at the top of DNS, a.root-servers.net to m.root-servers.net. They know which servers handle each ending, such as .com or .org.
  • Upstream: where Pi-hole sends the names it does not block. Here, Unbound.
  • DNSSEC: digital signatures on DNS answers. A resolver that checks them refuses answers that were changed on the way.
  • Cache: the answers your server keeps for a while, so the second lookup of a name is instant.

What Unbound changes for privacy, and what it does not

Unbound keeps every answer in its cache for as long as the answer allows, and it asks each server only what that server needs to know. That second part is QNAME minimisation, already on in the image we use: the root server is asked about org, not about www.example.org. In plain words:

  • No public DNS company receives the full list of names your home looks up. Each name server sees only the questions about its own part of DNS.
  • Those name servers do see your home's public IP address, because Unbound asks them directly.
  • DNS from Unbound to the internet is not encrypted (plain port 53), so your internet provider can still read the names. Hiding them from the provider takes encrypted DNS to a public service, such as Quad9 over DNS-over-HTTPS, which brings a middleman back. That is the trade-off.

Before you start

  • Pi-hole running in Docker Compose. This guide builds on the compose file from our Pi-hole with Docker Compose guide; with another Pi-hole setup the idea is the same: Unbound as a second service with a fixed address.
  • A free private range for the Docker network. We use 172.30.53.0/24; if your LAN or VPN already uses it, pick another /24 and change the three addresses in the compose file.
  • Outgoing DNS from the server to the internet on port 53, over UDP and TCP. Some routers and providers block it, or answer in place of the real servers. Check it on the server:
Code
dig @198.41.0.4 . NS +norec +time=3 | grep -E "status|flags"
dig @198.41.0.4 . NS +norec +tcp +time=3 | grep -E "status|flags"
dig @198.41.0.4 version.bind CH TXT +time=3 +short
Terminal on the home server: dig to the root server 198.41.0.4 over UDP and over TCP returns NOERROR with the flags qr aa, and version.bind returns ATLAS
1: over UDP. 2: over TCP. 3: the root server's own version answer.

198.41.0.4 is a.root-servers.net. Both lookups must show status: NOERROR and the flags qr aa. The aa flag (authoritative answer) means the root server itself answered, not a box on the way. If the TCP line times out, Unbound will fail on large DNSSEC answers, which need TCP. The last command asks the server for its version: a root server gives its own ("ATLAS" here), not the name of a home router or a provider's resolver.

Which Unbound image: klutchell/unbound, not mvance/unbound

Unbound in Docker comes from community images. We checked the one found in most older Pi-hole setups, mvance/unbound, the one we use, klutchell/unbound, and the latest Unbound release, on 25 November 2026:

Terminal on the laptop: Docker Hub shows mvance/unbound last updated 2024-10-19 at 1.21.1, klutchell/unbound updated 2026-11-24, and GitHub shows Unbound release-1.26.2 from 2026-10-21
1: mvance/unbound. 2: klutchell/unbound. 3: the latest Unbound release from NLnet Labs.

mvance/unbound was last updated on 19 October 2024 and stops at Unbound 1.21.1. klutchell/unbound was updated the day before our test and ships Unbound 1.26.2, the latest release from NLnet Labs (21 October 2026), the team that writes Unbound. It runs Unbound as a normal user (we check that in step 3) and includes drill-hc, a small DNS check made for container health checks. Use a version tag such as 1.26.2 rather than latest, so an update only happens when you choose it.

Step 1: Write the Unbound settings file

The image reads every .conf file in /etc/unbound/custom.conf.d/ on top of its own settings, so you only write the changes. In the folder that holds your Pi-hole compose.yaml (~/pihole in our Pi-hole guide):

Terminal
mkdir -p unbound && cat > unbound/pi-hole.conf <<'CONF'
server:
    # Give no name or version to "who are you" questions (version.bind, id.server)
    hide-identity: yes
    hide-version: yes
    # Receive buffer for bursts of answers (the host must allow it: net.core.rmem_max)
    so-rcvbuf: 1m
    # Cache sizes that stay well under the container's 256 MB memory limit
    msg-cache-size: 32m
    rrset-cache-size: 64m
    # Write the reason of each DNSSEC failure to the log
    val-log-level: 2
    # These names answer with private addresses on purpose (Plex, nip.io)
    private-domain: "plex.direct"
    private-domain: "nip.io"

remote-control:
    # unbound-control works inside the container only (127.0.0.1, port not published)
    control-enable: yes
    control-use-cert: no
CONF
Terminal: unbound/pi-hole.conf written with hide-identity, hide-version, so-rcvbuf, the two cache sizes, val-log-level, two private-domain lines and the remote-control block
1: the settings file. 2: the folder now holds pi-hole.conf.

What each part does:

  • hide-identity and hide-version: Unbound stops telling anyone who asks its name and version.
  • so-rcvbuf: 1m: a bigger network receive buffer, so a burst of answers is not dropped. Your host must allow it: see the production settings below.
  • msg-cache-size and rrset-cache-size: the two cache limits (the second about twice the first). 32 MB and 64 MB are far more than a home fills, and they stay well under the 256 MB memory limit in the compose file.
  • val-log-level: 2: when a DNSSEC check fails, the log says which name failed and why.
  • private-domain: Unbound refuses answers from the internet that point to private addresses such as 192.168.x.x, which protects your network from DNS rebinding attacks. Plex (plex.direct) and nip.io give such answers on purpose, so we allow those two domains only.
  • remote-control: turns on unbound-control, the command that shows statistics and empties the cache. It listens on 127.0.0.1 inside the container, and that port is not published, so nothing outside the container can reach it.

The difference is easy to see. With the image's defaults, before this file, Unbound told everyone its name and version, a nip.io name pointing to our server got no answer, and unbound-control did not work:

The image defaults before the settings file: version.bind answers unbound 1.26.2, the nip.io name gets 0 answers, and unbound-control fails because control-enable is no
The same checks with the image's defaults, before pi-hole.conf. 1: name and version given to anyone who asks. 2: the nip.io name gets no answer. 3: unbound-control is off.

Step 2: The production compose file for Pi-hole and Unbound

This is the compose file from our Pi-hole guide with two changes in the pihole service (it waits for Unbound, and Unbound is its only upstream) and a new unbound service. The password file pihole_password.txt and the etc-pihole folder stay as they are. Save it as compose.yaml:

YAML
services:
  pihole:
    image: pihole/pihole:2026.11.0
    container_name: pihole
    hostname: pihole
    restart: unless-stopped
    depends_on:
      unbound:
        condition: service_healthy
    ports:
      - "192.168.1.50:53:53/tcp"
      - "192.168.1.50:53:53/udp"
      - "192.168.1.50:80:80/tcp"
      - "192.168.1.50:443:443/tcp"
    environment:
      TZ: America/New_York
      FTLCONF_dns_listeningMode: ALL
      FTLCONF_dns_reply_host_force4: "true"
      FTLCONF_dns_reply_host_IPv4: 192.168.1.50
      FTLCONF_ntp_sync_active: "false"
      FTLCONF_dns_upstreams: 172.30.53.53
      WEBPASSWORD_FILE: pihole_webpasswd
    secrets:
      - pihole_webpasswd
    volumes:
      - ./etc-pihole:/etc/pihole
    cap_add:
      - SYS_NICE
    cap_drop:
      - NET_RAW
    mem_limit: 256m
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
  unbound:
    image: klutchell/unbound:1.26.2
    container_name: unbound
    hostname: unbound
    restart: unless-stopped
    networks:
      default:
        ipv4_address: 172.30.53.53
    volumes:
      - ./unbound:/etc/unbound/custom.conf.d:ro
    healthcheck:
      test: ["CMD", "drill-hc", "@127.0.0.1", "dnssec.works"]
      interval: 30s
      timeout: 30s
      retries: 3
      start_period: 30s
    cap_drop:
      - ALL
    cap_add:
      - SETUID
      - SETGID
    security_opt:
      - no-new-privileges:true
    mem_limit: 256m
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
networks:
  default:
    ipam:
      config:
        - subnet: 172.30.53.0/24
          ip_range: 172.30.53.128/25
secrets:
  pihole_webpasswd:
    file: ./pihole_password.txt
Terminal: the full compose.yaml with the pihole and unbound services, the fixed address 172.30.53.53, the health check and the network block, then docker compose config prints compose file OK
1: compose.yaml. 2: Compose reads it without errors.

The lines that matter:

  • ipv4_address: 172.30.53.53 and the networks block at the end: Unbound always gets the same address. ip_range: 172.30.53.128/25 makes Docker give other containers addresses from .128 up only, so none of them can take .53.
  • FTLCONF_dns_upstreams: 172.30.53.53: Pi-hole's only upstream, given as an address. Do not use the name unbound here; the startup trap below shows why.
  • healthcheck: every 30 seconds, drill-hc looks up dnssec.works through Unbound. With depends_on and condition: service_healthy, docker compose up starts Pi-hole only after Unbound answers.
  • ./unbound:/etc/unbound/custom.conf.d:ro: your settings folder, read-only inside the container.
  • cap_drop: ALL with only SETUID and SETGID added back, and no-new-privileges: Unbound keeps just the two rights it needs to switch to its own user.
  • No ports: for Unbound. Only Pi-hole talks to it, over the Docker network; devices on your LAN cannot reach it.
  • mem_limit: 256m and log rotation (three files of 10 MB) for both services, so neither can fill the memory or the disk.

Step 3: Start both and check the settings Unbound really uses

Pi-hole is recreated during this first start, and your home has no DNS until Unbound is healthy, which took under a minute in our lab. Pick a quiet moment:

Terminal
docker compose config --quiet && echo "compose file OK"
docker compose up -d
docker compose ps --format "table {{.Name}}\t{{.Image}}\t{{.Status}}"
docker compose logs unbound
docker compose up -d recreates the network, starts Unbound, waits until it is healthy and then starts Pi-hole; docker compose ps shows both; the Unbound log shows start of service (unbound 1.26.2)
1: Pi-hole starts only after Unbound is Healthy. 2: both running. 3: Unbound's start log.

Compose recreated the network (the address range is new), started Unbound, waited until it was Healthy, and only then started Pi-hole. The log line generate keytag query _ta-4f66-9728 is Unbound reporting to the root servers which DNSSEC root keys it trusts: 4f66 and 9728 are, in hexadecimal, the key tags 20326 and 38696 of the two root zone keys (from 2017 and 2024). Unbound keeps this key list current by itself, in a file inside the container.

Check the values in use with unbound-checkconf

unbound-checkconf checks the files, and with -o it prints the value Unbound will use for one option, including the image's own defaults:

Terminal
docker exec unbound unbound-checkconf
for o in hide-identity hide-version so-rcvbuf msg-cache-size rrset-cache-size val-log-level qname-minimisation aggressive-nsec prefetch serve-expired edns-buffer-size harden-dnssec-stripped; do echo "$o: $(docker exec unbound unbound-checkconf -o $o)"; done
docker exec pihole pihole-FTL --config dns.upstreams
docker inspect -f "{{.Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" pihole unbound
docker top unbound -o pid,user,comm
unbound-checkconf reports no errors; the values in use, from hide-identity yes and so-rcvbuf 1048576 to harden-dnssec-stripped yes; Pi-hole upstream 172.30.53.53; container addresses; Unbound runs as user 101
1: no errors. 2: the values Unbound uses. 3: Pi-hole's upstream. 4: the containers' addresses. 5: the user of the Unbound process.

Our six settings are there (in bytes: 1048576 is 1 MB). The next six are already on in this image, so you do not need to write them: QNAME minimisation; aggressive use of signed "this name does not exist" answers, which saves lookups; prefetch, which renews popular names before they expire; serve-expired, which serves an expired answer while it fetches a fresh one; a 1232-byte EDNS buffer, which avoids large UDP answers that some networks drop; and the hardening that rejects answers whose DNSSEC data was stripped. Pi-hole's upstream is [ 172.30.53.53 ], Unbound has that address, and the Unbound process runs as user 101, not as root.

Step 4: Check in Pi-hole's web interface

Under Settings, DNS, the Custom DNS servers box shows 172.30.53.53 and no public server is ticked. The address comes from the compose file (FTLCONF_dns_upstreams), which wins at every start, so change it there and not in this box.

Pi-hole Settings, DNS: the Custom DNS servers box contains 172.30.53.53
Settings, DNS, Custom DNS servers. 1: Unbound's address, set by the compose file.

On the dashboard, Upstream servers shows where answers come from: blocklist (names Pi-hole blocked), cache, and 172.30.53.53#53, which is Unbound. In the Query Log, click a name your home has not visited before: the status reads "Forwarded, reply from 172.30.53.53#53" and the DNSSEC status SECURE, as in the screenshot at the top of this guide.

Pi-hole dashboard, Upstream servers chart: blocklist, cache and 172.30.53.53#53
Dashboard, Upstream servers. 1: every answer comes from the blocklist, the cache or Unbound (172.30.53.53#53).

Step 5: Test DNSSEC, privacy and local names

From a laptop that uses Pi-hole, then the log on the server:

Code
dig @192.168.1.50 dnssec.works | grep -E "status|flags:|^dnssec"
dig @192.168.1.50 fail01.dnssec.works | grep -E "status|flags:"
docker compose logs unbound --since 1m | grep "validation failure"
From the laptop: dnssec.works answers NOERROR with the ad flag and 46.23.92.212; fail01.dnssec.works answers SERVFAIL; Unbound log: validation failure, no signatures from 185.92.221.212
1: valid signatures, ad flag. 2: broken signatures, SERVFAIL. 3: the reason in Unbound's log.

dnssec.works has valid signatures: NOERROR, an address, and the ad flag (authenticated data). fail01.dnssec.works has broken signatures on purpose: SERVFAIL and no address, so a device never receives a forged answer. Thanks to val-log-level: 2, the log gives the reason: "validation failure <fail01.dnssec.works. A IN>: no signatures from 185.92.221.212".

Check what others can see

Terminal
docker exec pihole dig @172.30.53.53 version.bind CH TXT +short; docker exec pihole dig @172.30.53.53 id.server CH TXT | grep status
dig @192.168.1.50 192-168-1-50.nip.io +short
dig @172.30.53.53 debian.org +time=2 +tries=1 | grep -E "timed out|reached|status"
version.bind gives no answer and id.server is REFUSED; 192-168-1-50.nip.io answers 192.168.1.50; from the laptop, 172.30.53.53 times out
1: no name, no version. 2: the nip.io name works. 3: Unbound cannot be reached from the LAN.

The version question now gets an empty answer and the name question gets REFUSED. The nip.io name answers 192.168.1.50 again. And the laptop cannot reach Unbound at all: only Pi-hole can.

Speed: slower for new names, instant from the cache

We saved 20 well-known sites in a file on the laptop and timed them through Pi-hole and Unbound with empty caches, then the same 20 again, then the same list straight from Google's 8.8.8.8:

Terminal
mkdir -p ~/unbound && cd ~/unbound && cat > names.txt <<'EOF'
wikipedia.org
github.com
debian.org
ubuntu.com
kernel.org
python.org
mozilla.org
apache.org
nginx.org
docker.com
tagesschau.de
lemonde.fr
bbc.co.uk
nhk.or.jp
nos.nl
svt.se
rtve.es
abc.net.au
cbc.ca
rai.it
EOF
cd ~/unbound && for run in first second; do s=$(date +%s%N); for n in $(cat names.txt); do dig @192.168.1.50 +short $n > /dev/null; done; echo "$run pass: $(( ($(date +%s%N) - s) / 1000000 )) ms for $(wc -l < names.txt) names"; done
cd ~/unbound && s=$(date +%s%N); for n in $(cat names.txt); do dig @8.8.8.8 +short $n > /dev/null; done; echo "8.8.8.8 directly: $(( ($(date +%s%N) - s) / 1000000 )) ms for $(wc -l < names.txt) names"
Speed test with 20 names: nlnetlabs.nl 339 ms then 0 ms; first pass 14896 ms and second pass 195 ms through Pi-hole and Unbound; 1145 ms straight from 8.8.8.8; Unbound counters; memory 14.81 MiB and 13.59 MiB
1: the 20 test names. 2: one new name, then the same name again. 3: 20 new names, then the same 20. 4: the same names straight from 8.8.8.8. 5: Unbound's counters. 6: memory.

The first pass took 14.9 seconds, about 0.74 seconds a name, because Unbound walked from the root for every new domain. The second pass took 0.2 seconds for all 20: cache. Google answered the 20 new names in 1.1 seconds, because most of them were already in its own cache, which millions of users fill. One name alone shows the same: nlnetlabs.nl took 339 ms the first time and 0 ms the second. Over six runs with empty caches, the first pass took between 11.2 and 14.9 seconds, and Google between 1.0 and 1.1 seconds.

Unbound's own counters after the tests: 114 queries, 6 answered from its cache, and 0.19 seconds on average for each lookup it made itself. Memory after all the tests: 14.81 MiB for Unbound and 13.59 MiB for Pi-hole. In daily use, the cache answers repeat visits and prefetch renews popular names before they expire, so the wait falls mostly on sites your home opens for the first time.

The startup trap: give Pi-hole an address, not a name

Our first compose file pointed Pi-hole at the name unbound (FTLCONF_dns_upstreams: unbound), which Docker's internal DNS turns into Unbound's address. It works, until Pi-hole starts while Unbound is not running. We stopped Unbound, restarted Pi-hole, then started Unbound again:

Terminal
docker stop unbound && docker restart pihole
docker compose logs pihole --since 30s | grep -iE "unbound|upstream|server|resolv|error|warn"
docker start unbound
Pi-hole upstream set to the name unbound; Unbound stopped and Pi-hole restarted; Pi-hole log CRIT Error in dnsmasq configuration: Name has no usable address; after Unbound is back, the laptop gets connection refused and nothing listens on UDP port 53
1: the upstream is a name. 2: Unbound stopped, Pi-hole restarted. 3: the CRIT error. 4-5: Unbound back and healthy. 6: DNS still refused. 7: nothing listens on port 53.

Pi-hole writes its upstream into its dnsmasq settings. With Unbound stopped, the name had no address, and Pi-hole's DNS engine rejected the whole configuration: "CRIT: Error in dnsmasq configuration: Name has no usable address at line 33 of /etc/pihole/dnsmasq.conf". The web interface kept running, but nothing listened on port 53 any more, and devices got "connection refused". Starting Unbound again did not help: DNS stayed down for the whole network until we restarted Pi-hole. Its health check turns unhealthy, but Docker does not restart a container for that.

With the fixed address, Pi-hole recovers by itself

The same test with FTLCONF_dns_upstreams: 172.30.53.53:

Terminal
docker stop unbound && docker restart pihole
docker compose logs pihole --since 30s | grep -E "CRIT|ERROR" | cut -c1-160
dig @192.168.1.50 ietf.org +time=5 +tries=1 | grep -E "status|refused|reached"
docker start unbound
dig @192.168.1.50 ietf.org +time=5 +tries=1 | grep -E "status|refused|reached|^ietf"
docker compose ps --format "table {{.Name}}\t{{.Status}}"
With the fixed address: Unbound stopped and Pi-hole restarted; Pi-hole logs Cannot receive UDP DNS reply: Timed out after 2000 ms; no answer while Unbound is down; NOERROR for ietf.org after docker start unbound
1: the same test. 2: Pi-hole waits for its upstream. 3: no answer while Unbound is down. 4: Unbound started. 5: answers again, Pi-hole untouched. 6: both healthy.

While Unbound was down, Pi-hole logged "Cannot receive UDP DNS reply: Timed out after 2000 ms" and devices got no answer, which is expected with one upstream. As soon as Unbound was back, the next lookup worked (NOERROR for ietf.org) without touching Pi-hole.

Reboot test

depends_on only applies when you run docker compose up. After a reboot, Docker starts the containers itself from their restart policy and does not wait for the health check. Restarting Docker shows what a reboot does:

Terminal
sudo systemctl restart docker
docker compose ps --format "table {{.Name}}\t{{.Status}}"
docker compose logs pihole --since 1m | grep -E "CRIT|ERROR"
sudo systemctl restart docker; both containers up 43 seconds and healthy; Pi-hole logged one UDP timeout; apache.org answers NOERROR with 151.101.2.132
1: Docker restarted, as in a reboot. 2: both healthy. 3: one timeout while Unbound was starting. 4: DNS works.

Both containers were healthy again after 43 seconds. Pi-hole logged one timeout, because it started before Unbound was ready, then answered normally: apache.org resolved through Unbound. With the name instead of the address, Pi-hole would need Unbound to be running at the exact moment it starts, and a reboot gives no such promise.

Production settings: what we kept and what we dropped

Every row was tested in the lab on 25 November 2026. The settings we kept are all in the two files above.

SettingValueWhyWhat we saw
Imageklutchell/unbound:1.26.2current Unbound, pinned tagupdated 24 Nov 2026; mvance/unbound last updated 19 Oct 2024 (1.21.1)
Pi-hole upstream172.30.53.53, fixed addressworks in any start orderby name: CRIT error and no DNS; by address: recovers alone
Start orderhealth check with drill-hc, depends_on: service_healthyPi-hole waits for a working UnboundUnbound Healthy, then Pi-hole starts
Name and versionhide-identity, hide-version: yesless for attackers to work withempty and REFUSED (before: "unbound 1.26.2")
Private answersprivate-domain: plex.direct, nip.iorebinding protection stays on for the restnip.io answers 192.168.1.50 (before: no answer)
DNSSEC failuresval-log-level: 2the log says why a name fails"no signatures from 185.92.221.212"
Statisticsremote-control on 127.0.0.1, port not publishedunbound-control stats and cache flushworks inside the container only
Cachemsg-cache-size: 32m, rrset-cache-size: 64mroom for a home, under the memory limit14.81 MiB used after our tests
Receive bufferso-rcvbuf: 1mfewer dropped answers in burstsno warning with our host limit (below)
Rightscap_drop: ALL + SETUID, SETGID; no-new-privilegesleast privilegeruns as user 101
Exposureno ports: for Unboundonly Pi-hole reaches itfrom the LAN: timed out
Limitsmem_limit: 256m, logs 3 x 10 MBprotects the hostboth under 15 MiB
Pi-hole DNSSECon (Use DNSSEC)SECURE or BOGUS for each namesame speed; 102 instead of 34 Unbound queries
Image defaultsQNAME minimisation, aggressive NSEC, prefetch, serve-expired, EDNS 1232, hardeningalready on, nothing to addchecked with unbound-checkconf -o
Droppedread-only containerUnbound writes its root key file"could not open autotrust file for writing"
Droppedcap_drop: ALL aloneUnbound switches to its own user at start"unable to set group id of unbound"
Droppedso-rcvbuf: 32mmore than the host allows"was not granted"

so-rcvbuf and net.core.rmem_max

Linux gives a program at most twice the host's net.core.rmem_max, and Unbound warns when it gets less than half of what it asked for. Our host allowed 4194304 bytes, so 1m, and even 8m, passed without a warning. To see the warning, we asked for 32m in a test file:

Code
sysctl net.core.rmem_max
printf "server:\n    so-rcvbuf: 32m\n" > unbound/zz-test.conf && docker compose restart unbound > /dev/null 2>&1; sleep 5; docker compose logs unbound --since 20s | grep -i rcvbuf
sysctl net.core.rmem_max = 4194304; with so-rcvbuf 32m Unbound warns: so-rcvbuf 33554432 was not granted. Got 8388608
1: the host limit. 2: 32 MB asked, 8 MB granted (twice the limit): warning.

On many Linux hosts the limit is 212992 bytes, and there 1m gives the same warning. The fix in the Pi-hole documentation is to raise the limit on the host to 1048576 with sysctl; our host did not need it, so we did not test that step. If you prefer to leave the host alone, delete the so-rcvbuf line and Unbound uses the system default.

Container rights: what Unbound needs

Code
timeout 20 docker run --rm --cap-drop ALL klutchell/unbound:1.26.2 2>&1 | grep -m1 fatal
timeout 20 docker run --rm --cap-drop ALL --cap-add SETUID --cap-add SETGID --read-only klutchell/unbound:1.26.2 2>&1 | grep -m1 fatal
docker run with --cap-drop ALL: fatal error unable to set group id of unbound; with SETUID and SETGID added and --read-only: fatal error could not open autotrust file for writing, Read-only file system
1: no capabilities at all. 2: the two it needs, in a read-only container.

With every capability dropped, Unbound stops at start: it cannot switch to its own user. With SETUID and SETGID back it starts, so the compose file keeps those two. A read-only container then fails another way: Unbound cannot update its root key file. That is why only the settings folder is read-only, not the whole container.

Pi-hole's own DNSSEC: keep it on

Unbound already checks DNSSEC, so we measured Pi-hole with its own check on and off, with both caches empty each time:

Terminal
docker exec pihole pihole-FTL --config dns.dnssec true
docker exec pihole pihole-FTL --config dns.dnssec false
Pi-hole DNSSEC true: first pass 11197 ms, second pass 196 ms, ad flag, SERVFAIL for fail01, 102 Unbound queries; false: 11694 ms, 198 ms, no ad flag, SERVFAIL, 34 queries
1-4: Pi-hole's DNSSEC on. 5-8: off. Both caches empty each time.
Pi-hole DNSSEC20 new namesSame 20 againdnssec.worksfail01.dnssec.worksQueries to Unbound
on11,197 ms196 msad flagSERVFAIL102
off11,694 ms198 msno ad flagSERVFAIL34

Speed was the same, and broken names failed either way, because Unbound blocks them. With Pi-hole's check on, devices get the ad flag and the Query Log shows SECURE or BOGUS for each name, which is worth the extra queries: Pi-hole also asks for the DS and DNSKEY records it needs for its own check. Keep it on: Settings, DNS, Use DNSSEC.

Update Unbound and Pi-hole

Both images have fixed tags. To update, look up the new version (the Unbound releases from NLnet Labs, the klutchell/unbound tags on Docker Hub, Pi-hole's Docker releases), change the tag in compose.yaml, then run:

Terminal
docker compose pull
docker compose up -d
docker compose pull pulls klutchell/unbound:1.26.2 and pihole/pihole:2026.11.0; docker compose up -d leaves both running and Unbound healthy
1: pull the tags written in compose.yaml. 2: apply them.

In our run both tags were current, so nothing changed: both containers kept running and Unbound was reported Healthy. With a new tag, Compose pulls it and recreates that container.

Troubleshooting

  • Every name fails with SERVFAIL. Run the root server check from "Before you start": without UDP and TCP port 53 to the internet, Unbound cannot work. Also check the server's clock: DNSSEC signatures carry dates, and a wrong clock makes valid answers look broken.
  • "CRIT: Error in dnsmasq configuration: Name has no usable address" in Pi-hole's log: the upstream is a name. Use Unbound's fixed address and restart Pi-hole.
  • "so-rcvbuf ... was not granted" in Unbound's log: the host limit is lower than the buffer you asked for. Raise net.core.rmem_max or delete the line.
  • "fatal error: unable to set group id of unbound": SETUID and SETGID are missing from cap_add.
  • "could not open autotrust file for writing": the container is read-only. Remove read_only.
  • A local name stopped working (Plex, nip.io, or any name that points to 192.168.x.x): add its domain as a private-domain line, then run docker compose restart unbound.
  • "control-enable is 'no'" from unbound-control: the remote-control block is missing.
  • "WARNING: Trying to free NULL pointer in readEnvValue()" in Pi-hole's log: it appeared at every start in our lab, with DNS working. You can ignore it.
  • A site opens slowly the first time only: that is the walk from the root. The next visit comes from the cache.

Frequently asked questions

Is Pi-hole with Unbound faster than Google or Cloudflare DNS?

Not for new names. In our tests a new name took 0.56 to 0.74 seconds through Unbound, against about 0.05 seconds from Google, whose cache is shared by millions of users. Names already in the cache answered in 0 ms, so the difference shows only the first time your home visits a site.

Does Unbound make my DNS private?

It removes the one company that sees all your lookups. It does not encrypt DNS: your internet provider can still read the names, and each name server sees the questions about its own domain together with your public IP address.

Should Pi-hole's DNSSEC stay on when Unbound already checks it?

Yes. In our test the speed was the same with it on or off, and bogus names failed either way. With it on, devices get the ad flag and the Query Log shows SECURE or BOGUS for each name.

How much memory does Unbound use?

14.81 MiB after all our tests, with cache limits of 32 MB and 64 MB and a container limit of 256 MB. The cache grows with use, but a home stays far below those limits.

Do I need to open a port on my router for Unbound?

No. Unbound only makes outgoing requests, like a browser. Do not publish Unbound's port at all, and publish Pi-hole's port 53 on the server's LAN address only, as in the compose file.

What happens to my network if Unbound stops?

Lookups fail for every device until Unbound is back, because it is Pi-hole's only upstream. restart: unless-stopped starts it again after a crash, and with the fixed address Pi-hole answers again on its own as soon as Unbound is up, as our test showed.

Do I need to download root.hints for Unbound in Docker?

No. Unbound has the root server addresses built in and asks a root server for the current list before its first lookup, so an old list does no harm. The DNSSEC root key is the part that must stay current, and Unbound updates that file by itself, which is why the container must not be read-only.

Is mvance/unbound still updated?

Not when we checked on 25 November 2026: its last update on Docker Hub was 19 October 2024, with Unbound 1.21.1. We use klutchell/unbound, which had Unbound 1.26.2, the latest release.

Sources

Salah Edin

Salah Edin

Salah Edin covers security advisories, Linux and DevOps for IGPROD.

Leave a comment

Your email address will not be published. Required fields are marked *

Your experience on this site will be improved by allowing cookies Cookie Policy