Skip to content

systemd socket activation fails on IPv6 #741

Description

@linuxgemini

Describe the bug
When unbound is run with systemd's socket activation (see additional information below for an example socket file); unless you set specific IPv4 addresses to listen (like 127.0.0.1:553) on the socket file and set do-ip6: no (also set port: 553 for this example) on unbound.conf, you will get these two error lines:

error: setsockopt(..., IPV6_V6ONLY, ...) failed: Invalid argument
fatal error: could not open ports

To reproduce
Steps to reproduce the behavior:

  1. Compile and install unbound with systemd support (--enable-systemd).
  2. Copy the built contrib/unbound.service from source to /usr/lib/systemd/system/.
  3. Install the systemd socket file below to /usr/lib/systemd/system/.
  4. Configure /usr/local/etc/unbound/unbound.conf like below.
  5. Reload systemd daemon. (systemctl daemon-reload)
  6. Start the unbound socket. (systemctl start unbound.socket)
  7. Start the unbound service. (systemctl start unbound.service)
  8. Check service log. (Assuming journald is installed, journalctl -xeu unbound)

Expected behavior
Unbound starting.

System:

  • Unbound version: 1.16.2
  • OS: Debian 11 (bullseye)
  • unbound -V output:
    Version 1.16.2
    
    Configure line: --enable-systemd --enable-subnet --enable-tfo-client --enable-tfo-server --enable-dnstap --enable-dnscrypt --enable-cachedb --enable-ipsecmod --enable-ipset --with-pthreads --with-dynlibmodule --with-pyunbound --with-pythonmodule --with-libevent=/usr --with-libexpat=/usr --with-libhiredis=/usr --with-libnghttp2=/usr --with-protobuf-c=/usr --with-libsodium=/usr --with-libmnl=/usr
    Linked libs: libevent 2.1.12-stable (it uses epoll), OpenSSL 1.1.1n  15 Mar 2022
    Linked modules: dns64 python dynlib cachedb ipsecmod subnetcache ipset 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
    

Additional information

File /usr/lib/systemd/system/unbound.socket:

[Socket]
BindIPv6Only=both

ListenDatagram=553
ListenStream=553

[Install]
WantedBy=sockets.target

File /usr/local/etc/unbound/unbound.conf:

server:
  verbosity: 1
  port: 553

  use-systemd: yes

  do-daemonize: no

  username: ""

python:

dynlib:

remote-control:
  control-enable: no

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