FreeBSD 14
Sponsored Link

Kea DHCP : Configure Server2025/03/13

 

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

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

root@dlp:~ #
vi /usr/local/etc/kea/kea-dhcp4.conf
# create new
{
"Dhcp4": {
    "interfaces-config": {
        # specify network interfaces to listen on
        "interfaces": [ "vtnet0" ]
    },
    # 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:~ #
service kea enable

root@dlp:~ #
service kea start

[3] It's possible to see leased IP address in the file below from DHCP Server to DHCP Clients.
root@dlp:~ #
ls -l /var/db/kea

total 10
-rw-r--r--  1 root wheel  41 Mar 13 11:07 kea-dhcp6-serverid
-rw-r--r--  1 root wheel 111 Mar 13 11:05 kea-leases4.csv
-rw-r--r--  1 root wheel 168 Mar 13 11:04 kea-leases6.csv

root@dlp:~ #
cat /var/db/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,1741827897,1,0,0,rx-0.,0,,0
10.0.0.200,00:0c:29:e5:f5:43,01:00:0c:29:e5:f5:43,3600,1741828116,1,0,0,rx-0.,0,,0
10.0.0.201,52:54:00:1e:27:13,ff:56:50:4d:98:00:02:00:00:ab:11:c8:77:4d:72:b6:0e:1b:84,3600,1741828325,1,0,0,ubuntu,0,,0
.....
.....
Matched Content