3.7. Assigning a static address to a host by using DHCP
In Kea, you can use a reservation inside a subnet definition to assign a fixed IP address to a media access control (MAC), a DHCP unique identifier (DUID), or other identifiers.
For example, use this method to always assign the same IP address to a server or network device.
Prerequisites
-
The
kea-dhcp4andkea-dhcp6services are configured and running. -
You are logged in as the
rootuser.
Procedure
If you are configuring an IPv4 network:
Edit the
/etc/kea/kea-dhcp4.conffile, and add a reservation to thesubnet4parameter:{ "Dhcp4": { "subnet4": [ { "subnet": "192.0.2.0/24", ..., "reservations": [ { "hw-address": "52:54:00:72:2f:6e", "ip-address": "192.0.2.130" } ], ...This example configures Kea to always assign the
192.0.2.130IP address to the host with the52:54:00:72:2f:6eMAC address.For further examples, see the
/usr/share/doc/kea/examples/kea4/reservations.jsonfile provided by thekea-docpackage.Verify the syntax of the configuration file:
# kea-dhcp4 -t /etc/kea/kea-dhcp4.confIf the command returns
Syntax check failed, fix the errors shown in the report.Restart the
kea-dhcp4service:# systemctl restart kea-dhcp4
If you are configuring an IPv6 network:
Edit the
/etc/kea/kea-dhcp6.conffile, and add a reservation to thesubnet6parameter:{ "Dhcp6": { "subnet6": [ { "subnet": "2001:db8:0:1::/64", ..., "reservations": [ { "hw-address": "52:54:00:72:2f:6e", "ip-address": "2001:db8:0:1::99" } ]; ...This example configures Kea to always assign the
2001:db8:0:1::99IP address to the host with the52:54:00:72:2f:6eMAC address.For further examples, see the
/usr/share/doc/kea/examples/kea6/reservations.jsonfile provided by thekea-docpackage.Verify the syntax of the configuration file:
# kea-dhcp6 -t /etc/kea/kea-dhcp6.confIf the command returns
Syntax check failed, fix the errors shown in the report.Restart the
kea-dhcp6service:# systemctl restart kea-dhcp6