Skip to content

Instantly share code, notes, and snippets.

@Skywalker-11
Last active December 3, 2023 15:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Skywalker-11/29ab856ed3c88f0eadc6e833f32fa78a to your computer and use it in GitHub Desktop.
Save Skywalker-11/29ab856ed3c88f0eadc6e833f32fa78a to your computer and use it in GitHub Desktop.
kea dhcp systemd service files for single instance

This systemd service files can be used to launch a single kea instance on a server.

This requires that the config files are located under /etc/kea/ and the config files themself match this pattern:

  • dhcp4 server: kea-dhcp6.conf
  • dhcp6 server: kea-dhcp4.conf
  • ddns server: kea-ddns.conf
  • ctrl agent: kea-ctrl-agent.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:

  • dhcp4 server: systemctl enable kea-dhcp4-server
  • dhcp6 server: systemctl enable kea-dhcp6-server
  • ddns server: systemctl enable kea-ddns-server
  • ctrl agent: systemctl enable kea-ctrl-agent

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/4911124c99a39572ade4065743bd3a54 for a version with multiple instances on a single server

[Unit]
Description=ISC KEA CTRL AGENT
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.conf
[Install]
WantedBy=kea-dhcp4-server.service
WantedBy=kea-dhcp6-server.service
[Unit]
Description=ISC KEA DDNS Service
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/kea-ddns.conf
[Install]
WantedBy=kea-dhcpv4-server.service
WantedBy=kea-dhcpv6-server.service
[Unit]
Description=ISC KEA IPv4 DHCP daemon
Documentation=man:kea-dhcp4(8)
Wants=network-online.target mariadb.service
Requires=kea-ctrl-agent.service
After=network-online.target mariadb.service mysql.service
[Service]
ExecStart=/usr/local/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf
[Install]
WantedBy=multi-user.target
[Unit]
Description=ISC KEA IPv6 DHCP daemon
Documentation=man:kea-dhcp6(8)
Wants=network-online.target mariadb.service
Requires=kea-ctrl-agent.service
After=network-online.target mariadb.service mysql.service
[Service]
ExecStart=/usr/local/sbin/kea-dhcp6 -c /etc/kea/kea-dhcp6.conf
[Install]
WantedBy=multi-user.target
@benleb
Copy link

benleb commented Jun 21, 2023

perfect, thanks!

a small bug to fix - the 4 in kea-dhcp4.conf of the ExecStart line is missing 👍

@Skywalker-11
Copy link
Author

perfect, thanks!

a small bug to fix - the 4 in kea-dhcp4.conf of the ExecStart line is missing +1

Fixed

@pierre-labastie
Copy link

In kea-ddns-server.service, the WantedBy lines have dhcpvx (with x=4 or x=6). The v should be removed

@pierre-labastie
Copy link

Also, with kea-2.4, it seems a line "RuntimeDirectory=kea" should be added, otherwise the daemons complain that they cannot create their pid files because /var/run/kea does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment