PiHole Works. Unbound Works. PiHole using Unbound does not

I have been using Pihole for about 6 months without any problems. To improve privacy, i thought I would try to integrate recursive dns using unbound.

I am using Pi-hole on a Raspberry Pi 3 using the latest version of Pi-hole (PI-HOLE V5.14.2 FTL V5.20 WEB INTERFACE V5.18) and Unbound (1.13.1).

I followed the instructions in the guide: unbound - Pi-hole documentation

I got Unbound setup and i can resolve websites using dig on my pihole server. However, when I go into the Pihole UI and configure it to use unbound it I am not able to resolve any dns.

Expected Behaviour:

Upon configuring the Unbound IP and PORT in the PiHole user interface, i am expecting to be able to resolve upstream dns records through PiHole using Unbound.

Example of Unbound working:

pi@Pihole:~ $ dig google.com @127.0.0.1 -p 5335

; <<>> DiG 9.16.33-Raspbian <<>> google.com @127.0.0.1 -p 5335
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3152
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             207     IN      A       172.253.115.102
google.com.             207     IN      A       172.253.115.113
google.com.             207     IN      A       172.253.115.138
google.com.             207     IN      A       172.253.115.139
google.com.             207     IN      A       172.253.115.100
google.com.             207     IN      A       172.253.115.101

;; Query time: 119 msec
;; SERVER: 127.0.0.1#5335(127.0.0.1)
;; WHEN: Tue Jan 03 21:12:40 EST 2023
;; MSG SIZE  rcvd: 135

Going to the Pihole interface, I unselect the IPV4 upstream DNS servers and select the Custom 1 DNS server (IPv4) and set it to 127.0.0.1#5335

At this time, DNS does not resolve.

If I go back to the server and do another dig, that too will report s SERVFAIL

pi@Pihole:~ $ dig google.com @127.0.0.1 -p 5335

; <<>> DiG 9.16.33-Raspbian <<>> google.com @127.0.0.1 -p 5335
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 48172
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;google.com.                    IN      A

;; Query time: 10 msec
;; SERVER: 127.0.0.1#5335(127.0.0.1)
;; WHEN: Tue Jan 03 21:53:34 EST 2023
;; MSG SIZE  rcvd: 39

Unbound Configuration:

server:
    # If no logfile is specified, syslog is used
    # logfile: "/var/log/unbound/unbound.log"
    verbosity: 0

    interface: 127.0.0.1
    port: 5335
    do-ip4: yes
    do-udp: yes
    do-tcp: yes

    # May be set to yes if you have IPv6 connectivity
    do-ip6: no

    # You want to leave this to no unless you have *native* IPv6. With 6to4 and
    # Terredo tunnels your web browser should favor IPv4 for the same reasons
    prefer-ip6: no

    # Use this only when you downloaded the list of primary root servers!
    # If you use the default dns-root-data package, unbound will find it automatically
    #root-hints: "/var/lib/unbound/root.hints"

    # Trust glue only if it is within the server's authority
    harden-glue: yes

    # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS
    harden-dnssec-stripped: yes

    # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes
    # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
    use-caps-for-id: no

    # Reduce EDNS reassembly buffer size.
    # IP fragmentation is unreliable on the Internet today, and can cause
    # transmission failures when large DNS messages are sent via UDP. Even
    # when fragmentation does work, it may not be secure; it is theoretically
    # possible to spoof parts of a fragmented DNS message, without easy
    # detection at the receiving end. Recently, there was an excellent study
    # >>> Defragmenting DNS - Determining the optimal maximum UDP response size for DNS <<<
    # by Axel Koolhaas, and Tjeerd Slokker (https://indico.dns-oarc.net/event/36/contributions/776/)
    # in collaboration with NLnet Labs explored DNS using real world data from the
    # the RIPE Atlas probes and the researchers suggested different values for
    # IPv4 and IPv6 and in different scenarios. They advise that servers should
    # be configured to limit DNS messages sent over UDP to a size that will not
    # trigger fragmentation on typical network links. DNS servers can switch
    # from UDP to TCP when a DNS response is too big to fit in this limited
    # buffer size. This value has also been suggested in DNS Flag Day 2020.
    edns-buffer-size: 1232

    # Perform prefetching of close to expired message cache entries
    # This only applies to domains that have been frequently queried
    prefetch: yes

    # One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1.
    num-threads: 1

    # Ensure kernel buffer is large enough to not lose messages in traffic spikes
    so-rcvbuf: 1m

    # Ensure privacy of local IP ranges
    private-address: 192.168.0.0/16
    private-address: 169.254.0.0/16
    private-address: 172.16.0.0/12
    private-address: 10.0.0.0/8
    private-address: fd00::/8
    private-address: fe80::/10

Actual Behaviour:

The browser reports DNS error. When I switch back to using UPSTREAM DNS SERVERS, everything works fine once again and I can resolved DNS through PiHole on both calling browsers and also on the Pi-Hole server via dig.

Your help is much appreciated. I used as much documentation and troubleshooting online as I can find. I have not been able to resolve this issue on my own so far. Anything you can offer for troubleshooting would be much appreciated.

Debug Token:

https://tricorder.pi-hole.net/lwSI7MUf/

Please provide the complete output of the following from the Pi terminal:

sudo grep -v '#\|^$' -R /etc/unbound/unbound.conf*

Here is the result:

192.168.1.1 is my router. I have my pihole server setup as my DNS server through my router.
(192.168.1.4 is my pi-hole + unbound server)

/etc/unbound/unbound.conf:include-toplevel: "/etc/unbound/unbound.conf.d/*.conf"
/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf:forward-zone:
/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf: name: "."
/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf: forward-addr: 192.168.1.1
/etc/unbound/unbound.conf.d/root-auto-trust-anchor-file.conf:server:
/etc/unbound/unbound.conf.d/root-auto-trust-anchor-file.conf: auto-trust-anchor-file: "/var/lib/unbound/root.key"
/etc/unbound/unbound.conf.d/pi-hole.conf:server:
/etc/unbound/unbound.conf.d/pi-hole.conf: verbosity: 0
/etc/unbound/unbound.conf.d/pi-hole.conf: interface: 127.0.0.1
/etc/unbound/unbound.conf.d/pi-hole.conf: port: 5335
/etc/unbound/unbound.conf.d/pi-hole.conf: do-ip4: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: do-udp: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: do-tcp: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: do-ip6: no
/etc/unbound/unbound.conf.d/pi-hole.conf: prefer-ip6: no
/etc/unbound/unbound.conf.d/pi-hole.conf: harden-glue: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: harden-dnssec-stripped: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: use-caps-for-id: no
/etc/unbound/unbound.conf.d/pi-hole.conf: edns-buffer-size: 1232
/etc/unbound/unbound.conf.d/pi-hole.conf: prefetch: yes
/etc/unbound/unbound.conf.d/pi-hole.conf: num-threads: 4
/etc/unbound/unbound.conf.d/pi-hole.conf: so-rcvbuf: 1m
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: 192.168.0.0/16
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: 169.254.0.0/16
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: 172.16.0.0/12
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: 10.0.0.0/8
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: fd00::/8
/etc/unbound/unbound.conf.d/pi-hole.conf: private-address: fe80::/10

Thoughts?

OS version is Raspbian GNU/Linux 11 (bullseye) - with the latest apt updates installed.

This unwanted configuration was installed by your OS. This is causing unbound to forward all the DNS queries to your router, and unbound is no longer operating in recursive mode.

  1. Edit file /etc/resolvconf.conf and comment out the last line which should then read:

#unbound_conf=/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf

  1. Delete the unwanted unbound configuration file:

sudo rm /etc/unbound/unbound.conf.d/resolvconf_resolvers.conf

  1. Restart unbound:

sudo service unbound restart

1 Like

Thank you so much. This corrected the issue. I am now able to use PiHole with Unbound and also be able to use it all through PiVPN via Wireshark.

I have no further needs at this time, but appreciate the extremely responsive support offered by the PiHole community.

1 Like

The whole openresolv issue has been finally brought to their repo: Conflicting with Unbound · Issue #15 · NetworkConfiguration/openresolv · GitHub

In hope I didn't comment to harsh there :sweat_smile:. Let's see what they think about it. I however just see that unbound_conf isn't defined in the default config, so when it's about changing the default, this might need to be addressed to Debian package maintainers instead, respectively a MR done at Salsa.

A post was split to a new topic: Unbound problems

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.