Skip to content

How to Test Unbound DNS on Raspberry Pi

A successful DNS lookup tells you the resolver answered. To check whether it rejects invalid DNSSEC signatures, compare a correctly signed domain with one that has deliberately broken signatures. If Unbound forwards to Quad9, a separate lookup can show whether Quad9 received your query over DNS over TLS (DoT).

1. Query the DNS server you want to test

Use dig from a device on your LAN. On Raspberry Pi OS, install the command with sudo apt install bind9-dnsutils if needed. Replace 192.168.1.42 with the LAN address of your Pi running Pi-hole or AdGuard Home.

1
2
3
# Query the Pi over UDP, then explicitly test TCP on the same DNS port.
dig @192.168.1.42 example.com. A +time=3 +tries=1
dig @192.168.1.42 example.com. A +tcp +time=3 +tries=1

Look for status: NOERROR and an IPv4 address under ANSWER SECTION. Both commands query the Pi directly for this lookup. The +tcp test checks plain DNS over TCP from your device to the Pi.

Open the Pi-hole or AdGuard Home query log and find the lookup. For a native Unbound listener bound to loopback, use a terminal on the Pi to run the same check against Unbound directly. If the first query after startup times out, try again with +time=12 +tries=2 to give a cold recursive resolver more time.

dig @127.0.0.1 -p 5335 example.com. A +time=3 +tries=1

If Unbound runs in a Compose network, 127.0.0.1 on the Pi refers to the host. Start with the LAN test and check the front end's configured upstream address. A direct query to the Unbound container needs a client that can reach its address on the Compose network.

2. Test DNSSEC with a good and a broken signature

Run all three queries against the same DNS listener. These examples target a native Unbound listener on the Pi. To repeat them through Pi-hole or AdGuard Home, replace @127.0.0.1 -p 5335 with the LAN address such as @192.168.1.42.

1
2
3
4
5
6
7
8
# A correctly signed domain.
dig @127.0.0.1 -p 5335 cloudflare.com. A +dnssec

# A test domain with deliberately bad DNSSEC data.
dig @127.0.0.1 -p 5335 dnssec-failed.org. A +dnssec

# Ask the resolver to skip validation for this one diagnostic query.
dig @127.0.0.1 -p 5335 dnssec-failed.org. A +dnssec +cdflag
Query Result to look for
Signed domain NOERROR and an answer. A trusted validating resolver can also set the ad flag for authenticated data.
Broken domain SERVFAIL is expected when the resolver rejects the invalid DNSSEC data.
Broken domain with +cdflag If it returns NOERROR and an answer, the change from SERVFAIL points to validation as the reason the ordinary query failed.

+dnssec requests DNSSEC records. The resolver performs validation. Use the result pair to check the path you queried. Behind Pi-hole or AdGuard Home, this can show that a resolver in the chain rejected bad data. Query Unbound's own listener to narrow down the path. If you get a timeout or both broken-domain queries fail, inspect Unbound's log and upstream settings before drawing a conclusion. ICANN's DNSSEC test procedure

3. Check whether Unbound forwards to Quad9 over TLS

In a direct recursive setup, Unbound resolves uncached names by querying the DNS hierarchy. With a root forward zone named ".", it sends matching upstream queries to a recursive provider. Check the configuration the service loads, including its included files. If its control interface is already enabled, sudo unbound-control list_forwards lists the active forward zones. Unbound forwarding options, Unbound control commands

If you followed the AdGuard Home and Unbound setup, run this from the Pi.

dig @127.0.0.1 -p 5335 proto.on.quad9.net. TXT +time=3 +tries=1 +short

A response of "dot" means Quad9 received that lookup over DNS over TLS. "do53-udp" means Quad9 received plain DNS over UDP. An empty result needs a full dig response to distinguish a timeout from a reply such as NXDOMAIN. Use this check when Quad9 is your configured forwarder. Quad9 protocol test

For authenticated DoT, check for forward-tls-upstream: yes, CA certificates such as those loaded with tls-cert-bundle, and an authentication name on the target such as 9.9.9.9@853#dns.quad9.net. If you configured forwarding without recursive fallback, check for forward-first: no. These settings apply to the connection from Unbound to Quad9. Unbound TLS settings, Quad9 service addresses

On a Pi 4B with Unbound 1.26.2 forwarding to Quad9 over authenticated TLS, the signed lookup returned NOERROR with ad. The broken-signature lookup returned SERVFAIL and then NOERROR with +cdflag. The protocol query returned "dot".

Find the failing part

What you see What to check next
The LAN query times out Check the Pi's address, the front end's port 53 listener and the LAN firewall. Compare UDP with TCP.
Unbound answers directly, but the LAN lookup fails Check the front end's query log, configured upstream address and filtering rules.
The resolver replies REFUSED Check that its access rules allow the client or front end that sent the query.
Many public names return SERVFAIL Look for upstream errors and an incorrect clock. For DoT, also check CA certificates, the configured TLS name and outbound TCP port 853.
Only the broken-signature test returns SERVFAIL Compare with the signed test and the single +cdflag query before changing any settings.

On an apt-based Unbound installation, inspect the configuration and recent service messages on the Pi. For Compose, use the log command from the directory with your Compose file and adjust the service name if needed.

1
2
3
4
5
6
# Native Unbound service
sudo unbound-checkconf
sudo journalctl -u unbound -n 30 --no-pager

# Unbound in Docker Compose
docker compose logs --tail=30 unbound
Donate