Error "reason: bind: Address already in use" when using same socket for dhcp4 and dhcp6
The example in chapter 7.2 suggests that it is possible to run both dhcp4 and dhcp6 server on the same unix socket (https://gitlab.isc.org/isc-projects/kea/blob/master/doc/guide/agent.xml#L70-80).
I noticed that in my setup (2 server HA load balance) on system startup it is not possible to start both a dhcp4 and dhcp6 server at the same simultaneously. One of them fails to start with error the other one start correctly:
ERROR [kea-dhcp4.dhcp4/676] DHCP4_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/<conffile>.conf, reason: bind: Address already in use
ERROR [kea-dhcp4.dhcp4/676] DHCP4_INIT_FAIL failed to initialize Kea server: configuration error using file '/etc/kea/<conffile>.conf': bind: Address already in use
Starting them manually one after another work with the same socket name
To Reproduce Steps to reproduce the behavior:
- Setup Kea with HA in load balancing mode and use the same socket-name for dhcp4 and dhcp6 in ctrl-agent and server config
- Setup systemd services for kea:
[Unit]
Description=ISC KEA CTRL AGENT (%I)
Documentation=man:kea-ctrl-agent(8)
Wants=network-online.target
After=network-online.target time-sync.target
[Service]
ExecStart=/usr/local/sbin/kea-ctrl-agent -c /etc/kea/kea-ctrl-agent-%i.conf
[Install]
WantedBy=kea-dhcp4-server@%i.service
WantedBy=kea-dhcp6-server@%i.service
[Unit]
Description=ISC KEA IPv4 DHCP daemon (%I)
Documentation=man:kea-dhcp4(8)
Wants=network-online.target mariadb.service
Requires=kea-ctrl-agent@%i.service
After=network-online.target mariadb.service mysql.service
[Service]
ExecStart=/usr/local/sbin/kea-dhcp4 -d -c /etc/kea/kea-dhcp4-%i.conf
[Install]
WantedBy=multi-user.target
[Unit]
Description=ISC KEA IPv6 DHCP daemon (%I)
Documentation=man:kea-dhcp6(8)
Wants=network-online.target mariadb.service
Requires=kea-ctrl-agent@%i.service
After=network-online.target mariadb.service mysql.service
[Service]
ExecStart=/usr/local/sbin/kea-dhcp6 -d -c /etc/kea/kea-dhcp6-%i.conf
[Install]
WantedBy=multi-user.target
- enable the services `systemctl enable kea-dhcp4-server@neta.service kea-dhcp6-server@neta.service
- reboot the server
- See error
systemd[1]: Started ISC KEA CTRL AGENT (vlan19).
systemd[1]: Started ISC KEA IPv4 DHCP daemon (vlan19).
systemd[1]: Started ISC KEA IPv6 DHCP daemon (vlan19).
...
INFO [kea-dhcp4.dhcp4/678] DHCP4_STARTING Kea DHCPv4 server version 1.4.0-P1 starting
DEBUG [kea-dhcp4.dhcp4/678] DHCP4_OPEN_SOCKET opening sockets on port 67
DEBUG [kea-dhcp4.commands/678] COMMAND_REGISTERED Command list-commands registered
...
DEBUG [kea-dhcp4.commands/678] COMMAND_REGISTERED Command statistic-remove-all registered
DEBUG [kea-dhcp6.dhcp6/679] DHCP6_START_INFO pid: 679, port: 547, verbose: yes
INFO [kea-dhcp6.dhcp6/679] DHCP6_STARTING Kea DHCPv6 server version 1.4.0-P1 starting
DEBUG [kea-dhcp6.dhcp6/679] DHCP6_OPEN_SOCKET opening sockets on port 547
DEBUG [kea-dhcp6.commands/679] COMMAND_REGISTERED Command list-commands registered
...
DEBUG [kea-dhcp6.commands/679] COMMAND_REGISTERED Command statistic-remove-all registered
DEBUG [kea-dhcp6.dhcp6/679] DHCP6_COMMAND_RECEIVED received command config-set, arguments: { ....
DEBUG [kea-dhcp4.dhcp4/678] DHCP4_COMMAND_RECEIVED received command config-set, arguments: { ....
ERROR [kea-dhcp6.dhcp6/679] DHCP6_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/kea-dhcp6-neta.conf, reason: bind: Address already in use
ERROR [kea-dhcp6.dhcp6/679] DHCP6_INIT_FAIL failed to initialize Kea server: configuration error using file '/etc/kea/kea-dhcp6-neta.conf': bind: Address already in use
systemd[1]: kea-dhcp6-server@neta.service: Main process exited, code=exited, status=1/FAILURE
Which of the dhcp4 or dhcp6 services crashes seems to depend on which service is first started by systemd
Expected behavior Both dhcp4 and dhcp6 server should start up
Environment:
- Kea version: 1.4.0-P1 (from tar.gz source)
- OS: Debian 9
./configure --with-mysql --with-tier2=yes
- Hooks: libdhcp_lease_cmds and libdhcp_ha