Pihole+Unbound prevents one single device from accessing the internet

That unit configures resolv.conf to point to the own host 127.0.0.1 for DNS resolution:

pi@ph5a:~ $ systemctl cat unbound-resolvconf.service
# /lib/systemd/system/unbound-resolvconf.service
[Unit]
Description=Unbound DNS server via resolvconf

Expecting that Unbound is default listening on 127.0.0.1 port 53.
But its not bc the guide has changed the default 53 port into 5335 instead.
So the whole purpose of that unit is broken if change the default.

Yes.
Can be your router IP if it doesnt close a DNS loop, your ISP provided DNS servers or public DNS providers like Google Cloudflare, Quad9 etc.
Reason, if you break Unbound or Pi-hole while tweaking/updating etc, you wont break DNS resolution for the processes on the Pi-hole host.
If you break Unbound or Pi-hole, you wouldn't even be able to upload a Pi-hole debug log.

Cant help you with that.

Sorry, two more questions:

1). By doing this, will it no longer use Unbound for DNS resolving and begin using the different upstream provider or will it just use the different upstream provider as a secondary DNS?

Currently, my setup looks like this: Unifi controller is set as DHCP > Pihole is set as DNS > Using Unbound > And then I have conditional forwarding in the Pihole pointing back to my router - the Unifi controller (not sure if that matters in this conversation)

2). In my Pihole, the DNS is set to 127.0.0.1#5335. How can I tell if Unbound is currently listening on port 53 or on port 5335? I followed the latest guide for installing Unbound, so the settings from there are what I have. The "customizations" in the config file I added today based on others saying they helped with the "sluggishness" of Unbound. But honestly, I can't tell if they're doing anything.

If you disable that unbound-resolvconf.service, DNS settings will revert back to those that were configured before installing Unbound (might need a reboot).

pi@ph5b:~ $ sudo ss -nltup "sport = 53 || sport = 5335"
Netid           State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port          Process
udp             UNCONN           0                0                                0.0.0.0:53                            0.0.0.0:*              users:(("pihole-FTL",pid=19678,fd=6))
udp             UNCONN           0                0                              127.0.0.1:5335                          0.0.0.0:*              users:(("unbound",pid=19820,fd=3))
udp             UNCONN           0                0                                      *:53                                  *:*              users:(("pihole-FTL",pid=19678,fd=8))
tcp             LISTEN           0                32                               0.0.0.0:53                            0.0.0.0:*              users:(("pihole-FTL",pid=19678,fd=7))
tcp             LISTEN           0                256                            127.0.0.1:5335                          0.0.0.0:*              users:(("unbound",pid=19820,fd=4))
tcp             LISTEN           0                32                                  [::]:53                               [::]:*              users:(("pihole-FTL",pid=19678,fd=9))

sudo ss -nltup "sport = 53 || sport = 5335"

root@DietPi:/etc# sudo ss -nltup "sport = 53 || sport = 5335"
Netid   State    Recv-Q   Send-Q     Local Address:Port     Peer Address:Port   
udp     UNCONN   0        0                0.0.0.0:53            0.0.0.0:*       users:(("pihole-FTL",pid=28499,fd=4))
udp     UNCONN   0        0              127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=28563,fd=5))
udp     UNCONN   0        0              127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=28563,fd=3))
udp     UNCONN   0        0                      *:53                  *:*       users:(("pihole-FTL",pid=28499,fd=6))
tcp     LISTEN   0        32               0.0.0.0:53            0.0.0.0:*       users:(("pihole-FTL",pid=28499,fd=5))
tcp     LISTEN   0        256            127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=28563,fd=6))
tcp     LISTEN   0        256            127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=28563,fd=4))
tcp     LISTEN   0        32                  [::]:53               [::]:*       users:(("pihole-FTL",pid=28499,fd=7))

Does this look okay?

Looks dandy

Bit awkward though that unbound with PID 28563 is listening twice on the same socket.

Yeah...not sure why that is.

You have duplicates below:

That might explain and might also be the cause of your initial issues :wink:

Hmmm....so which one should be the "master" config?

I realized you have lots of duplicates when checking the rgrep output.
I think you'll have to sort that out first.

I would stick with the guides recommendations and remove the duplicate ones:

https://docs.pi-hole.net/guides/dns/unbound/#configure-unbound

Thats why I asked you to revert to the guides defaults ... its a bit messy right now :wink:
From there on you could always expand.

Ow you have mine to compare:

pi@ph5a:~ $ sudo rgrep -v '^ *#\|^$' /etc/unbound/unbound.conf*
/etc/unbound/unbound.conf:include: "/etc/unbound/unbound.conf.d/*.conf"
/etc/unbound/unbound.conf.d/remote-control.conf:remote-control:
/etc/unbound/unbound.conf.d/remote-control.conf:    control-enable: yes
/etc/unbound/unbound.conf.d/qname-minimisation.conf:server:
/etc/unbound/unbound.conf.d/qname-minimisation.conf:    qname-minimisation: yes
/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: 1
/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

sudo ss -nltup "sport = 53 || sport = 5335"

Netid   State    Recv-Q   Send-Q     Local Address:Port     Peer Address:Port   
udp     UNCONN   0        0                0.0.0.0:53            0.0.0.0:*       users:(("pihole-FTL",pid=1868,fd=4))
udp     UNCONN   0        0              127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=2747,fd=3))
udp     UNCONN   0        0                      *:53                  *:*       users:(("pihole-FTL",pid=1868,fd=6))
tcp     LISTEN   0        32               0.0.0.0:53            0.0.0.0:*       users:(("pihole-FTL",pid=1868,fd=5))
tcp     LISTEN   0        256            127.0.0.1:5335          0.0.0.0:*       users:(("unbound",pid=2747,fd=4))
tcp     LISTEN   0        32                  [::]:53               [::]:*       users:(("pihole-FTL",pid=1868,fd=7))

Yay - looks like yours now.

I deleted the "extra" config file unbound.conf that was in /etc/unbound/unbound.conf.d and now the only config file being read in /etc/unbound/unbound.conf.d is the pi-hole.conf.

The only thing I don't have that you do is the:

/etc/unbound/unbound.conf.d/remote-control.conf:remote-control:
/etc/unbound/unbound.conf.d/remote-control.conf:    control-enable: yes

You did have before:

Its not part of the official guide though.

The last thing I'm struggling with was getting logging set up when following the official guide.

Part of the guide here:


"On modern Debian/Ubuntu-based Linux systems, you'll also have to add an AppArmor exception for this new file so unbound can write into it.

Create (or edit if existing) the file /etc/apparmor.d/local/usr.sbin.unbound and append

/var/log/unbound/unbound.log rw,

to the end (make sure this value is the same as above). Then reload AppArmor using

sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.unbound
sudo service unbound restart"

The issue here is AppArmor. I keep getting:

Warning: unable to find a suitable fs in /proc/mounts, is it mounted? Use --subdomainfs to override.

When I run sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.unbound

I've created the directories, the files, got the permissions set, I've installed apparmor and apparmor-utils. I tried googling this issue but keep getting 'compile a new kernel" results and that doesn't seem right when the official guide says this should just work out of the box with a default install of Unbound.

Any thoughts on this one? After this, I'll leave you alone :slight_smile: Thank you very much for all of your help so far.

What do you need the logs for?

Client query logging can be looked up in the Pi-hole logs and long term database.
If its for diagnosing, you only have to up verbosity to the level that you desire and loopup the logs with journalctl:

Well, considering the earlier issues I was having with Unbound, I thought that having the logging would have helped sooner.

But yes, you're right. It's not super needed.

Thank you again!

1 Like

Check the man page for syntax like for example show only entries for -s today:

man journalctl

Or grep -g if your distro supports it.

Thank you. Will do.

I actually just thought of one more question that maybe you can help me answer.

With the DNS resolver being Unbound that’s listening on port 5335, so I still need firewall rules allowing LAN traffic to port 53?

Yes 53 UDP & TCP only for DNS.
Dont need a rule for 5335 bc this traffic is all happening on the isolated loopback interface named lo that cant be accessed from your LAN:

pi@ph5b:~ $ ip -br link show lo
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
pi@ph5b:~ $ ip -br address show lo
lo               UNKNOWN        127.0.0.1/8 ::1/128

Ports are described in the docs as well:

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