Configuring a Kea DHCPv4 Service
kea-dhcp4 service.
- Make a backup copy of the original configuration file.The installed configuration files include comments and example settings that could be helpful as you configure a network. With a backup, you can edit the original copy while preserving the original file contents.
sudo cp /etc/kea/kea-dhcp4.conf /etc/kea/kea-dhcp4.conf.bak - Open
/etc/kea/kea-dhcp4.conf, then replace the contents with the following example text:{ "Dhcp4": { "interfaces-config": { "interfaces": [ "<interface name>" ] }, "lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/kea-leases4.csv" }, "valid-lifetime": 4000, "option-data": [ { "name": "domain-name-servers", "data": "<DNS server IP addresses>" } ], "subnet4": [ { "id": 1, "subnet": "<subnet IP address/netmask>", "option-data": [ { "name": "routers", "data": "<router IP address>" } ], "pools": [{ "pool": "<IP address range>" }] } ], "loggers": [ { "name": "kea-dhcp4", "output-options": [ { "output": "stdout" } ], "severity": "INFO" } ] } } - Replace placeholder values with values that apply to your network.
- Replace the value of
interfaceswith names of interfaces on which you want the service to listen for DHCP messages.For example:"interfaces": [ "eno1" ] - Review the parameters and values in
lease-databaseand make any changes that suit the needs of your network.Consider changing any of the following parameters:-
type—The type of databasekea-dhcp4uses.memfileis the default. In this case, the service keeps lease information in memory and saves the information to a CSV file on disk.If you have set up a MySQL or PostgreSQL database for lease database storage, you can change the value to
mysqlorpostgresql. See the Kea Administrator's Reference Manual for more information. -
persist—Boolean that indicates whetherkea-dhcp4saves lease database information to disk.trueis the default. If you set tofalse, a system restart would causekea-dhcp4to lose a record of which IP addresses have been assigned. -
name—The absolute path to the database file. Kea provides a default CSV file forkea-dhcp4in/var/lib/kea/kea-leases4.csv, but you can enter a custom value here.
-
- Review the value of
valid-lifetimeand change the value to suit the needs of your network.Enter an integer representing the number of seconds the leases assigned by the server are valid. - In
option-data, underdomain-name-servers, replace thedatavalue with the IP addresses of name servers you want to use.For example:"name": "domain-name-servers", "data": "10.0.2.10, 10.0.2.11" - Replace the
subnetvalue with the subnet IP address on your network.For example:"subnet": "10.0.2.0/24", - Replace the
poolvalue with a range of IP addresses within the subnet you have defined.For example:"pool": "10.0.2.20 - 10.0.2.100", - Review the values in
loggersand change any values to suit the needs of your network.
- Replace the value of
- Save the configuration file.
- Check the configuration file for syntax errors.
kea-dhcp4 -t /etc/kea/kea-dhcp4.conf - Enable and start the DHCP service.
sudo systemctl enable --now kea-dhcp4