Skip to content

When used with systemd-networkd, unbound does not start until systemd-networkd-wait-online.service times out #773

Description

@dryya

Describe the bug

As described in this arch linux bug report, "unbound waits for the network to be on (as stipulated in its service file) and systemd waits for the DNS resolver to be up before declaring that the network is on. The cycle only breaks when systemd network initialization times out and finally the unbound service file is allowed to start." The behavior started to occur with commit afbc7bb . Unbound and the network still work perfectly fine afterwards, it's just that DNS resolution doesn't come up until after the timeout period for systemd's network target.

To reproduce

On arch linux enable the systemd-networkd and unbound systemd services. Systemd-resolved is disabled. I don't believe it's relevant but I included a minimal resolvconf config file too.

/etc/unbound/unbound.conf
server:
	verbosity: 1
	trust-anchor-file: "/etc/unbound/trusted-key.key"
	tls-cert-bundle: "/etc/ssl/cert.pem"
	tls-system-cert: yes
python:
dynlib:
remote-control:
forward-zone:
	name: "."
	forward-tls-upstream: yes
	forward-addr: 1.1.1.1@853#cloudflare-dns.com
/etc/systemd/network/20-wired.network 
[Match]
Name=enp31s0
[Network]
DHCP=yes
[DHCPv4]
UseDNS=no
[DHCPv6]
UseDNS=no
/etc/resolvconf.conf
name_servers="::1 127.0.0.1"
resolv_conf_options="trust-ad"

Some more information on what's happening via systemd logs:

Output from ❯ systemctl status systemd-networkd-wait-online.service:

× systemd-networkd-wait-online.service - Wait for Network to be Configured
     Loaded: loaded (/usr/lib/systemd/system/systemd-networkd-wait-online.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/systemd-networkd-wait-online.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Sat 2022-10-29 22:49:12 CDT; 13min ago
       Docs: man:systemd-networkd-wait-online.service(8)
    Process: 621 ExecStart=/usr/lib/systemd/systemd-networkd-wait-online (code=exited, status=1/FAILURE)
   Main PID: 621 (code=exited, status=1/FAILURE)
        CPU: 9ms

22:47:12 arch systemd[1]: Starting Wait for Network to be Configured...
22:49:12 arch systemd-networkd-wait-online[621]: Timeout occurred while waiting for network connectivity.
22:49:12 arch systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FAILURE
22:49:12 arch systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
22:49:12 arch systemd[1]: Failed to start Wait for Network to be Configured.

And you can see via journalctl --boot unbound only begins afterwards:

Oct 29 22:49:12 arch systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
Oct 29 22:49:12 arch systemd[1]: Failed to start Wait for Network to be Configured.
Oct 29 22:49:12 arch systemd[1]: Reached target Network is Online.
Oct 29 22:49:12 arch systemd[1]: Starting Validating, recursive, and caching DNS resolver...
Oct 29 22:49:12 arch unbound[1432]: [1432:0] notice: init module 0: subnetcache

System:

  • OS: Linux arch 6.0.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 26 Oct 2022 15:25:45 +0000 x86_64 GNU/Linux
  • unbound -V output:
❯ unbound -V
Version 1.17.0

Configure line: --prefix=/usr --sysconfdir=/etc --localstatedir=/var --sbindir=/usr/bin --disable-rpath --enable-dnscrypt --enable-dnstap --enable-pie --enable-relro-now --enable-subnet --enable-systemd --enable-tfo-client --enable-tfo-server --enable-cachedb --with-libhiredis --with-conf-file=/etc/unbound/unbound.conf --with-pidfile=/run/unbound.pid --with-rootkey-file=/etc/trusted-key.key --with-libevent --with-libnghttp2 --with-pyunbound
Linked libs: libevent 2.1.12-stable (it uses epoll), OpenSSL 1.1.1q  5 Jul 2022
Linked modules: dns64 cachedb subnetcache respip validator iterator
DNSCrypt feature available
TCP Fastopen feature available

BSD licensed, see LICENSE in source package for details.
Report bugs to unbound-bugs@nlnetlabs.nl or https://github.com/NLnetLabs/unbound/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions