unbound-docker: Unbound does not start when passing custom unbound.conf mvance/ubound-rpi
Hello I receive the below error when attempting to load a custom unbound.conf file:
[1561868398] unbound[1:0] error: can’t bind socket: Cannot assign requested address for ::1 port 53
Not sure what could be causing this, my file appears to be valid when tested with a local installation of unbound. Any suggestion would be great. I am using the mvance/ubound-rpi image for docker.
Contents of unbound.conf
`# Unbound configuration file for Debian.
See the unbound.conf(5) man page.
See /usr/share/doc/unbound/examples/unbound.conf for a commented
reference config file.
The following line includes additional configuration files from the
/etc/unbound/unbound.conf.d directory.
#include: “*.conf”
server: # If no logfile is specified, syslog is used logfile: # “/var/log/unbound/unbound.log” verbosity: 0 port: 5353 do-ip4: yes do-udp: yes do-tcp: yes # May be set to yes if you have IPv6 connectivity do-ip6: no # Use this only when you downloaded the list of primary root servers! root-hints: “root.hints” # Trust glue only if it is within the servers 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. Suggested by the unbound man page # to reduce fragmentation reassembly problems edns-buffer-size: 1472 # 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`
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (13 by maintainers)
I’m not a fan of running as
--net=host
. It can be a security risk in some situations. There should be a more elegant solution.I think the issue may be with having the interface set to 127.0.0.1. With Docker networking, that’s probably not doing what you think/want. Try this instead:
Is there a reason you need it to be on port 5335? I know you want to avoid a conflict with Pi-hole, but you should be able to change the public port and keep the container port on 53 if you like (i.e.,
publish=5335:53/tcp --publish=5335:53/udp
). It may be worth trying since the issue seems somewhat port related. If you do, just swap out 5335 with 53 in the port and interface settings.You may also want to add the following to your config (by default only localhost is allowed and the rest are refused):
One other issue I see appears to be related to the log file location. The specified path (
/opt/unbound/etc/unbound/unbound.log
) does not exist by default within the container which is likely why it’s giving a permission denied error (that and it’s in the default chroot location and root privileges are dropped after the port is bound). I don’t think that’s causing your problem, but may still be worth resolving.I don’t currently run Pi-hole with Unbound so the others on here may be of more help than me. If you haven’t already, you might also look over https://github.com/MatthewVance/unbound-docker/issues/35.
Please report future issues related to the unbound-rpi image at https://github.com/MatthewVance/unbound-docker-rpi.
You should remove
so-rcvbuf: 1m
from your config to use the default (the default inherits the underlying system value). Your config should no longer cause a conflict because it will match whatever value used by the base OS image (i.e., theFROM debian:stretch
in the Dockerfile).so-rcvbuf
is for performance, not Pi-hole functionality (see Unbound documentation included below for reference). I doubt your Raspberry Pi will experience enough load to worry about such optimizations (if extra Unbound optimization is needed beyond the defaults, you probably shouldn’t be running on a Pi).While you could spend the time to optimize the image to support a higher value, it wouldn’t be worth the trouble. If you want some increased performance custom tuned to your Pi, look at how the shell script that builds the default conf file dynamically calculates values based on OS support.
Also keep in mind that Docker is a container, not a full VM. One way this difference comes into play is with permissions. While the Docker service may be run as a root user and a container often runs as root user by default, the root user in a running container does not have full rights to change the underlying Docker host. By default, Docker uses the Linux capabilities support to limit the rights of the “root” user within the container. See https://docs.docker.com/engine/security/security/#linux-kernel-capabilities.
It’s also worth noting this particular Unbound image runs Unbound within the container as the user
_unbound
, not as the “root” user by default. However, your config doesn’t appear to setusername: "_unbound"
, meaning you’re missing out on the improved security from dropping user privileges.From Howto Optimise:
From Unbound documentation:
If it helps, the unbound.conf file I use on my Pi currently is:
Excellent. Everything else working now?
On Sat, Jul 13, 2019, 8:54 PM nlt6444 notifications@github.com wrote:
You should also consider adding more of the config options I provided in the example config file. While the Unbound guide on the Pi-hole site applies a few security and privacy tricks, I took quite a bit of care to take advantage of several more such features.
The main ones Unbound supports that are not currently taken advantage of are related to running Unbound as a recursive server. Those are things like the root.hints you added and some TLS server related settings (see https://github.com/MatthewVance/unbound-docker/issues/13 and https://github.com/MatthewVance/unbound-docker/issues/14).