Skip to content

Instantly share code, notes, and snippets.

@Skywalker-11
Last active Apr 19, 2021
Embed
What would you like to do?
kea dhcp systemd service files for multiple instances

This systemd service files can be used to launch multiple kea instances with different configs on the same server eg. for mutliple vlans or network interfaces

This requires that the config files of each instance are located under /etc/kea/<instanceid>/ and the config files themself also match this pattern:

  • dhcp4 server: kea-dhcp6-<instanceid>.conf
  • dhcp6 server: kea-dhcp4-<instanceid>.conf
  • ddns server: kea-ddns-<instanceid>.conf
  • ctrl agent: kea-ctrl-agent-<instanceid>.conf

You can name them differently but then have to adjust the service files accordingly

The service files can used by copying them to the systemd service directory (eg. on debian /lib/systemd/system/ /etc/systemd/system/). Then enable the different kea services by running this commands for each kea instance on that server:

  • dhcp4 server: systemctl enable kea-dhcp4-server@<instanceid>
  • dhcp6 server: systemctl enable kea-dhcp6-server@<instanceid>
  • ddns server: systemctl enable kea-ddns-server@<instanceid>
  • ctrl agent: systemctl enable kea-ctrl-agent@<instanceid>

If you want that the kea services automatically restart if they crash you can add Restart=always to the [Service] section of the service files.

See https://gist.github.com/Skywalker-11/29ab856ed3c88f0eadc6e833f32fa78a for a version with a single kea instance on a server

[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/%i/kea-ctrl-agent-%i.conf
[Install]
WantedBy=kea-dhcp4-server@%i.service
WantedBy=kea-dhcp6-server@%i.service
[Unit]
Description=ISC KEA DDNS Service (%I)
Documentation=man:kea-dhcp-ddns(8)
Wants=network-online.target
After=network-online.target time-sync.target
[Service]
ExecStart=/usr/local/sbin/kea-dhcp-ddns -c /etc/kea/%i/kea-ddns-%i.conf
[Install]
WantedBy=kea-dhcpv4-server@%i.service
WantedBy=kea-dhcpv6-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 -c /etc/kea/%i/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 -c /etc/kea/%i/kea-dhcp6-%i.conf
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment