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
interfaces
with 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-database
and make any changes that suit the needs of your network.Consider changing any of the following parameters:-
type
—The type of databasekea-dhcp4
uses.memfile
is 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
mysql
orpostgresql
. See the Kea Administrator's Reference Manual for more information. -
persist
—Boolean that indicates whetherkea-dhcp4
saves lease database information to disk.true
is the default. If you set tofalse
, a system restart would causekea-dhcp4
to 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-dhcp4
in/var/lib/kea/kea-leases4.csv
, but you can enter a custom value here.
-
- Review the value of
valid-lifetime
and 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 thedata
value 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
subnet
value with the subnet IP address on your network.For example:"subnet": "10.0.2.0/24",
- Replace the
pool
value 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
loggers
and 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