CentOS Stream 10
Sponsored Link

Kea DHCP : Configure Server2025/03/12

 

Configure DHCP ( Dynamic Host Configuration Protocol ) Server to assign IP addresses to client hosts in local network.

[1] Install Kea DHCP.
[root@dlp ~]#
dnf -y install kea
[2] Configure Kea DHCP. This example shows only IPv4.
[root@dlp ~]#
mv /etc/kea/kea-dhcp4.conf /etc/kea/kea-dhcp4.conf.org

[root@dlp ~]#
vi /etc/kea/kea-dhcp4.conf
# create new
{
"Dhcp4": {
    "interfaces-config": {
        # specify network interfaces to listen on
        "interfaces": [ "enp1s0" ]
    },
    # settings for expired-leases (follows are default)
    "expired-leases-processing": {
        "reclaim-timer-wait-time": 10,
        "flush-reclaimed-timer-wait-time": 25,
        "hold-reclaimed-time": 3600,
        "max-reclaim-leases": 100,
        "max-reclaim-time": 250,
        "unwarned-reclaim-cycles": 5
    },
    # T1 timer that govern when the client begins the renewal processes (sec)
    "renew-timer": 900,
    # T2 timer that govern when the client begins the rebind processes (sec)
    "rebind-timer": 1800,
    # how long the addresses (leases) given out by the server are valid (sec)
    "valid-lifetime": 3600,
    "option-data": [
        {
            # specify your DNS server
            # to specify multiple entries, separate them with commas
            "name": "domain-name-servers",
            "data": "10.0.0.10"
        },
        {
            # specify your domain name
            "name": "domain-name",
            "data": "srv.world"
        },
        {
            # specify your domain-search base
            # to specify multiple entries, separate them with commas
            "name": "domain-search",
            "data": "srv.world"
        },
    ],
    "subnet4": [
        {
            "id": 1,
            # specify subnet that DHCP is used
            "subnet": "10.0.0.0/24",
            # specify the range of IP addresses to be leased
            "pools": [ { "pool": "10.0.0.200 - 10.0.0.254" } ],
            "option-data": [
                {
                    # specify your gateway
                    "name": "routers",
                    "data": "10.0.0.1"
                }
            ],
        }
    ],
    # logging settings
    "loggers": [
    {
        "name": "kea-dhcp4",
        "output-options": [
            {
                "output": "/var/log/kea/kea-dhcp4.log"
            }
        ],
        "severity": "INFO",
        "debuglevel": 0
    }
  ]
}
}

[root@dlp ~]#
chown root:kea /etc/kea/kea-dhcp4.conf

[root@dlp ~]#
chmod 640 /etc/kea/kea-dhcp4.conf

[root@dlp ~]#
systemctl enable --now kea-dhcp4

[3] If Firewalld is running, allow DHCP service. DHCP Server uses [67/UDP].
[root@dlp ~]#
firewall-cmd --add-service=dhcp

success
[root@dlp ~]#
firewall-cmd --runtime-to-permanent

success
[4] It's possible to see leased IP address in the file below from DHCP Server to DHCP Clients.
[root@dlp ~]#
ll /var/lib/kea

total 8
-rw-r--r--. 1 kea kea 272 Mar 12 10:43 kea-leases4.csv
-rw-r--r--. 1 kea kea 194 Mar 12 10:40 kea-leases4.csv.2
-rw-r-----. 1 kea kea   0 Feb 17 09:00 kea-leases6.csv

[root@dlp ~]#
cat /var/lib/kea/kea-leases4.csv

address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id
10.0.0.200,00:0c:29:e5:f5:43,01:00:0c:29:e5:f5:43,3600,1741743703,1,0,0,,2,,0
10.0.0.200,00:0c:29:e5:f5:43,01:00:0c:29:e5:f5:43,3600,1741747381,1,0,0,rx-0.,0,,0
.....
.....
Matched Content