Unable to install unbound

Following the official documentation on how to install unbound. After running command

sudo service unbound restart 
dig pi-hole.net @127.0.0.1 -p 5335

I get the error:

Job for unbound.service failed because the control process exited with error code.
See "systemctl status unbound.service" and "journalctl -xe" for details.

systemctl status unbound.service returns

● unbound.service - Unbound DNS server
   Loaded: loaded (/lib/systemd/system/unbound.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2022-06-03 12:49:53 BST; 1min 19s ago
     Docs: man:unbound(8)
  Process: 10389 ExecStartPre=/usr/lib/unbound/package-helper chroot_setup (code=exited, status=1/FAILURE)
  Process: 10392 ExecStartPre=/usr/lib/unbound/package-helper root_trust_anchor_update (code=exited, status=1/FAILURE)
  Process: 10395 ExecStart=/usr/sbin/unbound -d $DAEMON_OPTS (code=exited, status=1/FAILURE)
 Main PID: 10395 (code=exited, status=1/FAILURE)

Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Service RestartSec=100ms expired, scheduling restart.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Scheduled restart job, restart counter is at 5.
Jun 03 12:49:53 raspberrypi systemd[1]: Stopped Unbound DNS server.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Start request repeated too quickly.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Failed with result 'exit-code'.
Jun 03 12:49:53 raspberrypi systemd[1]: Failed to start Unbound DNS server.

and journalctl -xe

-- the configured Restart= setting for the unit.
Jun 03 12:49:53 raspberrypi systemd[1]: Stopped Unbound DNS server.
-- Subject: A stop job for unit unbound.service has finished
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A stop job for unit unbound.service has finished.
-- 
-- The job identifier is 312457 and the job result is done.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Start request repeated too quickly.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- The unit unbound.service has entered the 'failed' state with result 'exit-code'.
Jun 03 12:49:53 raspberrypi systemd[1]: Failed to start Unbound DNS server.
-- Subject: A start job for unit unbound.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A start job for unit unbound.service has finished with a failure.
-- 
-- The job identifier is 312457 and the job result is failed.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound-resolvconf.service: Start request repeated too quickly.
Jun 03 12:49:53 raspberrypi systemd[1]: unbound-resolvconf.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- The unit unbound-resolvconf.service has entered the 'failed' state with result 'exit-code'.
Jun 03 12:49:53 raspberrypi systemd[1]: Failed to start Unbound DNS server via resolvconf.
-- Subject: A start job for unit unbound-resolvconf.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A start job for unit unbound-resolvconf.service has finished with a failure.
-- 
-- The job identifier is 312515 and the job result is failed.
Jun 03 12:50:01 raspberrypi CRON[10404]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun 03 12:50:01 raspberrypi CRON[10405]: (root) CMD (   PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker local)
Jun 03 12:50:02 raspberrypi CRON[10404]: pam_unix(cron:session): session closed for user root
lines 3600-3641/3641 (END)

I tried to install unbound previously and couldn't connect to any site (which may be my next issue) so I tried to troubleshoot. I couldn't get it to work so I then uninstalled unbound to try again. My technical skills are extremely limited to when I was troubleshooting I messed something up as I didn't get this error the first time.

If needed, output on sudo grep -v ‘#|^$’ -R /etc/unbound/unbound.conf*

/etc/unbound/unbound.conf.d/pi-hole.conf:server:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # If no logfile is specified, syslog is used
/etc/unbound/unbound.conf.d/pi-hole.conf:    # logfile: "/var/log/unbound/unbound.log"
/etc/unbound/unbound.conf.d/pi-hole.conf:    verbosity: 0
/etc/unbound/unbound.conf.d/pi-hole.conf:
/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:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # May be set to yes if you have IPv6 connectivity
/etc/unbound/unbound.conf.d/pi-hole.conf:    do-ip6: no
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # You want to leave this to no unless you have *native* IPv6. With 6to4 and
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Terredo tunnels your web browser should favor IPv4 for the same reasons
/etc/unbound/unbound.conf.d/pi-hole.conf:    prefer-ip6: no
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Use this only when you downloaded the list of primary root servers!
/etc/unbound/unbound.conf.d/pi-hole.conf:    # If you use the default dns-root-data package, unbound will find it automatically
/etc/unbound/unbound.conf.d/pi-hole.conf:    #root-hints: "/var/lib/unbound/root.hints"
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Trust glue only if it is within the server's authority
/etc/unbound/unbound.conf.d/pi-hole.conf:    harden-glue: yes
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS
/etc/unbound/unbound.conf.d/pi-hole.conf:    harden-dnssec-stripped: yes
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes
/etc/unbound/unbound.conf.d/pi-hole.conf:    # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
/etc/unbound/unbound.conf.d/pi-hole.conf:    use-caps-for-id: no
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Reduce EDNS reassembly buffer size.
/etc/unbound/unbound.conf.d/pi-hole.conf:    # IP fragmentation is unreliable on the Internet today, and can cause
/etc/unbound/unbound.conf.d/pi-hole.conf:    # transmission failures when large DNS messages are sent via UDP. Even
/etc/unbound/unbound.conf.d/pi-hole.conf:    # when fragmentation does work, it may not be secure; it is theoretically
/etc/unbound/unbound.conf.d/pi-hole.conf:    # possible to spoof parts of a fragmented DNS message, without easy
/etc/unbound/unbound.conf.d/pi-hole.conf:    # detection at the receiving end. Recently, there was an excellent study
/etc/unbound/unbound.conf.d/pi-hole.conf:    # >>> Defragmenting DNS - Determining the optimal maximum UDP response size for DNS <<<
/etc/unbound/unbound.conf.d/pi-hole.conf:    # by Axel Koolhaas, and Tjeerd Slokker (https://indico.dns-oarc.net/event/36/contributions/776/)
/etc/unbound/unbound.conf.d/pi-hole.conf:    # in collaboration with NLnet Labs explored DNS using real world data from the
/etc/unbound/unbound.conf.d/pi-hole.conf:    # the RIPE Atlas probes and the researchers suggested different values for
/etc/unbound/unbound.conf.d/pi-hole.conf:    # IPv4 and IPv6 and in different scenarios. They advise that servers should
/etc/unbound/unbound.conf.d/pi-hole.conf:    # be configured to limit DNS messages sent over UDP to a size that will not
/etc/unbound/unbound.conf.d/pi-hole.conf:    # trigger fragmentation on typical network links. DNS servers can switch
/etc/unbound/unbound.conf.d/pi-hole.conf:    # from UDP to TCP when a DNS response is too big to fit in this limited
/etc/unbound/unbound.conf.d/pi-hole.conf:    # buffer size. This value has also been suggested in DNS Flag Day 2020.
/etc/unbound/unbound.conf.d/pi-hole.conf:    edns-buffer-size: 1232
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Perform prefetching of close to expired message cache entries
/etc/unbound/unbound.conf.d/pi-hole.conf:    # This only applies to domains that have been frequently queried
/etc/unbound/unbound.conf.d/pi-hole.conf:    prefetch: yes
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # 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.
/etc/unbound/unbound.conf.d/pi-hole.conf:    num-threads: 1
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Ensure kernel buffer is large enough to not lose messages in traffic spikes
/etc/unbound/unbound.conf.d/pi-hole.conf:    so-rcvbuf: 1m
/etc/unbound/unbound.conf.d/pi-hole.conf:
/etc/unbound/unbound.conf.d/pi-hole.conf:    # Ensure privacy of local IP ranges
/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
/etc/unbound/unbound.conf.d/pi-hole.conf:

check your configuration files for typos, using unbound-checkconf, man here.

depending on the version you have installed (and the platform), you might get "command not found". In that case, run "which unbound-checkconf", and use the complete output, including path to repeat the command (example /usr/sbin/unbound-checkconf).

You appear to missing the unbound configuration file that tells unbound to read the pihole configuration file.

/etc/unbound/unbound.conf:include-toplevel: "/etc/unbound/unbound.conf.d/*.conf"

1 Like

Thank you. I created the file which resolved the error and unbound is now active. Was this okay?

sudo nano /etc/unbound/unbound.conf

And within the file

include: "/etc/unbound/unbound.conf.d/*.conf"

However, I now have the issue where most sites don't load. My browser says "Hmm. We’re having trouble finding that site. We can’t connect to the server at [website].com". This may be an issue for another post

I see this solution: Unbound starts failing when I set pi.hole to use it? - #3 by Norlig

However, within /etc/resolvconf.conf

unbound_conf=/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf does not exist.

The final line within my file is: unbound_conf=/var/cache/unbound/resolvconf_resolvers.conf

I commented that out and removed the file, but it did not fix the issue.

Almost:

pi@ph5b:~ $ cat /etc/unbound/unbound.conf
[..]
include-toplevel: "/etc/unbound/unbound.conf.d/*.conf"

From your grep output, your distro seems not affected by above linked issue you posted.
If so, you would have had lines similar like below:

/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: 8.8.8.8
/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf:  forward-addr: 8.8.4.4

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