[Kea-users] Running out of leases - config/cleanup issue

Haakon Storm Heen mail at haakonstorm.com
Mon Jul 15 10:25:13 UTC 2019


Hello all!

Sorry for bad english and including a lot of text, logs and config in a single email. 

- I've installed KEA DHCP server on a macOS 10.14 server at a client site.

- IPs are given out according to config, but after some time runs out of addresses and the network halts. I'm really not sure what is happening, but my configuration has to have an error somewhere. I guess something related to lease times in relation to _cleanup_.
- On a hunch, I redefined the subnet from `10.0.1.1/24` to `10.0.1.0/24` and back again - might be why I have both `kea-leases4.cs ` and  `kea-leases4.csv.2 ` ?
- What happens is that when I run out addresses, if I remove the two .csv lease files and `sudo keactrl reload` and all is well again.

Tips on getting my config right?


## Main bulk of kea-dhcp4.conf:

```json
{
    "Dhcp4": {
        "interfaces-config": {
            "interfaces": [
                "en0"
            ]
        },
        "control-socket": {
            "socket-type": "unix",
            "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
        },
        "lease-database": {
            "type": "memfile",
            "lfc-interval": 3600
        },
        "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
        },
        "renew-timer": 900,
        "rebind-timer": 1800,
        "valid-lifetime": 3600,
        "option-data": [
            {
                "name": "domain-name-servers",
                "data": "10.0.1.4"
            },
            {
                "name": "domain-search",
                "data": "ourexternaldomain.tld, local"
            },
            {
                "name": "boot-file-name",
                "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
            },
            {
                "name": "default-ip-ttl",
                "data": "0xf0"
            }
        ],
        "client-classes": [
            {
                "name": "voip",
                "test": "substring(option[60].hex,0,6) == 'Aastra'",
                "next-server": "192.0.2.254",
                "server-hostname": "hal9000",
                "boot-file-name": "/dev/null"
            }
        ],
        "subnet4": [
            {
                "subnet": "10.0.1.1/24",
                "pools": [
                    {
                        "pool": "10.0.1.100 - 10.0.1.230"
                    }
                ],
                "option-data": [
                    {
                        "name": "routers",
                        "data": "10.0.1.1"
                    }
                ],
                "reservations": [
                    {
                        "hw-address": "78:8a:20:44:b4:83",
                        "ip-address": "10.0.1.1"
                    },
-----snip-------
                    {
                        "hw-address": "00:e0:81:ed:a5:8b",
                        "ip-address": "10.0.1.50"
                    },
                    {
                        "hw-address": "b4:fb:e4:82:b6:49",
                        "ip-address": "10.0.1.51"
                    }
                ]
            }
        ]
    },
    "Logging": {
        "loggers": [
            {
                "name": "kea-dhcp4",
                "output_options": [
                    {
                        "output": "/usr/local/var/log/kea-dhcp4.log"
                    }
                ],
                "severity": "INFO",
                "debuglevel": 0
            }
        ]
    }
}
```



## Main output of kea-dhcp4.log



```
2019-07-12 17:41:33.088 INFO  [kea-dhcp4.leases/1304] DHCP4_LEASE_ALLOC [hwtype=1 48:bf:6b:f2:98:08], cid=[01:48:bf:6b:f2:98:08], tid=0xdefa2929: lease 10.0.1.100 has been allocated
2019-07-12 17:43:55.514 INFO  [kea-dhcp4.dhcp4/1304] DHCP4_SHUTDOWN server shutdown
2019-07-12 17:44:13.705 INFO  [kea-dhcp4.hosts/74] HOSTS_BACKENDS_REGISTERED the following host backend types are available: 
2019-07-12 17:44:13.707 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_ADD_IFACE listening on interface en0
2019-07-12 17:44:13.707 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using default socket type raw
2019-07-12 17:44:13.712 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: 10.0.1.0/24 with params: t1=900, t2=1800, valid-lifetime=3600
2019-07-12 17:44:13.713 INFO  [kea-dhcp4.commands/74] COMMAND_ACCEPTOR_START Starting to accept connections via unix domain socket bound to /tmp/kea-dhcp4-ctrl.sock
2019-07-12 17:44:13.714 INFO  [kea-dhcp4.dhcp4/74] DHCP4_CONFIG_COMPLETE DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
2019-07-12 17:44:13.714 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_DB opening memory file lease database: lfc-interval=3600 type=memfile universe=4
2019-07-12 17:44:13.727 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /usr/local/var/kea/kea-leases4.csv
2019-07-12 17:44:13.728 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 3600 sec
2019-07-12 17:44:13.729 WARN  [kea-dhcp4.dhcpsrv/74] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface en0 has no usable IPv4 addresses configured
2019-07-12 17:44:13.729 WARN  [kea-dhcp4.dhcpsrv/74] DHCPSRV_NO_SOCKETS_OPEN no interface configured to listen to DHCP traffic
2019-07-12 17:44:13.730 INFO  [kea-dhcp4.dhcp4/74] DHCP4_STARTED Kea DHCPv4 server version 1.5.0 started
2019-07-12 17:54:21.572 INFO  [kea-dhcp4.dhcp4/74] DHCP4_SHUTDOWN server shutdown
2019-07-12 17:54:43.880 INFO  [kea-dhcp4.hosts/74] HOSTS_BACKENDS_REGISTERED the following host backend types are available: 
2019-07-12 17:54:43.882 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_ADD_IFACE listening on interface en0
2019-07-12 17:54:43.882 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using default socket type raw
2019-07-12 17:54:43.887 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: 10.0.1.1/24 with params: t1=900, t2=1800, valid-lifetime=3600
2019-07-12 17:54:43.889 INFO  [kea-dhcp4.commands/74] COMMAND_ACCEPTOR_START Starting to accept connections via unix domain socket bound to /tmp/kea-dhcp4-ctrl.sock
2019-07-12 17:54:43.890 INFO  [kea-dhcp4.dhcp4/74] DHCP4_CONFIG_COMPLETE DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
2019-07-12 17:54:43.890 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_DB opening memory file lease database: lfc-interval=3600 type=memfile universe=4
2019-07-12 17:54:43.891 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /usr/local/var/kea/kea-leases4.csv
2019-07-12 17:54:43.892 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 3600 sec
2019-07-12 17:54:43.892 WARN  [kea-dhcp4.dhcpsrv/74] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface en0 has no usable IPv4 addresses configured
2019-07-12 17:54:43.892 WARN  [kea-dhcp4.dhcpsrv/74] DHCPSRV_NO_SOCKETS_OPEN no interface configured to listen to DHCP traffic
2019-07-12 17:54:43.907 INFO  [kea-dhcp4.dhcp4/74] DHCP4_STARTED Kea DHCPv4 server version 1.5.0 started
2019-07-12 18:54:44.607 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_START starting Lease File Cleanup
2019-07-12 18:54:44.607 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_EXECUTE executing Lease File Cleanup using: /usr/local/sbin/kea-lfc -4 -x /usr/local/var/kea/kea-leases4.csv.2 -i /usr/local/var/kea/kea-leases4.csv.1 -o /usr/local/var/kea/kea-leases4.csv.output -f /usr/local/var/kea/kea-leases4.csv.completed -p /usr/local/var/kea/kea-leases4.csv.pid -c ignored-path
2019-07-12 19:54:44.625 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_START starting Lease File Cleanup
2019-07-12 19:54:44.626 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_EXECUTE executing Lease File Cleanup using: /usr/local/sbin/kea-lfc -4 -x /usr/local/var/kea/kea-leases4.csv.2 -i /usr/local/var/kea/kea-leases4.csv.1 -o /usr/local/var/kea/kea-leases4.csv.output -f /usr/local/var/kea/kea-leases4.csv.completed -p /usr/local/var/kea/kea-leases4.csv.pid -c ignored-path
2019-07-12 20:54:44.874 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_START starting Lease File Cleanup
2019-07-12 20:54:44.874 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_EXECUTE executing Lease File Cleanup using: /usr/local/sbin/kea-lfc -4 -x /usr/local/var/kea/kea-leases4.csv.2 -i /usr/local/var/kea/kea-leases4.csv.1 -o /usr/local/var/kea/kea-leases4.csv.output -f /usr/local/var/kea/kea-leases4.csv.completed -p /usr/local/var/kea/kea-leases4.csv.pid -c ignored-path
2019-07-12 21:54:45.050 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_START starting Lease File Cleanup
----snip---(many similar lines)
2019-07-15 09:55:18.426 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_EXECUTE executing Lease File Cleanup using: /usr/local/sbin/kea-lfc -4 -x /usr/local/var/kea/kea-leases4.csv.2 -i /usr/local/var/kea/kea-leases4.csv.1 -o /usr/local/var/kea/kea-leases4.csv.output -f /usr/local/var/kea/kea-leases4.csv.completed -p /usr/local/var/kea/kea-leases4.csv.pid -c ignored-path
2019-07-15 10:55:18.486 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_START starting Lease File Cleanup
2019-07-15 10:55:18.488 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_EXECUTE executing Lease File Cleanup using: /usr/local/sbin/kea-lfc -4 -x /usr/local/var/kea/kea-leases4.csv.2 -i /usr/local/var/kea/kea-leases4.csv.1 -o /usr/local/var/kea/kea-leases4.csv.output -f /usr/local/var/kea/kea-leases4.csv.completed -p /usr/local/var/kea/kea-leases4.csv.pid -c ignored-path
2019-07-15 11:48:51.986 INFO  [kea-dhcp4.dhcp4/74] DHCP4_DYNAMIC_RECONFIGURATION initiate server reconfiguration using file: /usr/local/etc/kea/kea-dhcp4.conf, after receiving SIGHUP signal
2019-07-15 11:48:51.987 INFO  [kea-dhcp4.hosts/74] HOSTS_BACKENDS_REGISTERED the following host backend types are available: 
2019-07-15 11:48:51.987 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_ADD_IFACE listening on interface en0
2019-07-15 11:48:51.987 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using default socket type raw
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: 10.0.1.1/24 with params: t1=900, t2=1800, valid-lifetime=3600
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcp4/74] DHCP4_CONFIG_COMPLETE DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_DB opening memory file lease database: lfc-interval=3600 type=memfile universe=4
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /usr/local/var/kea/kea-leases4.csv.2
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /usr/local/var/kea/kea-leases4.csv
2019-07-15 11:48:51.988 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 3600 sec
2019-07-15 11:48:52.331 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 78:8a:20:59:aa:c1], cid=[01:78:8a:20:59:aa:c1], tid=0x772ae5fe: lease 10.0.1.7 will be advertised
2019-07-15 11:48:52.341 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ALLOC [hwtype=1 78:8a:20:59:aa:c1], cid=[01:78:8a:20:59:aa:c1], tid=0x772ae5fe: lease 10.0.1.7 has been allocated
----snip----
2019-07-15 11:49:58.035 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 68:5b:35:84:eb:96], cid=[01:68:5b:35:84:eb:96], tid=0x4cc297b0: lease 10.0.1.2 will be advertised
2019-07-15 11:49:59.055 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ALLOC [hwtype=1 68:5b:35:84:eb:96], cid=[01:68:5b:35:84:eb:96], tid=0x4cc297b0: lease 10.0.1.2 has been allocated
2019-07-15 11:50:10.665 INFO  [kea-dhcp4.dhcp4/74] DHCP4_DYNAMIC_RECONFIGURATION initiate server reconfiguration using file: /usr/local/etc/kea/kea-dhcp4.conf, after receiving SIGHUP signal
2019-07-15 11:50:10.666 INFO  [kea-dhcp4.hosts/74] HOSTS_BACKENDS_REGISTERED the following host backend types are available: 
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_ADD_IFACE listening on interface en0
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using default socket type raw
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: 10.0.1.1/24 with params: t1=900, t2=1800, valid-lifetime=3600
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcp4/74] DHCP4_CONFIG_COMPLETE DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_DB opening memory file lease database: lfc-interval=3600 type=memfile universe=4
2019-07-15 11:50:10.667 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /usr/local/var/kea/kea-leases4.csv
2019-07-15 11:50:10.668 INFO  [kea-dhcp4.dhcpsrv/74] DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 3600 sec
2019-07-15 12:01:55.777 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc20: lease 10.0.1.43 will be advertised
2019-07-15 12:02:12.685 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc22: lease 10.0.1.43 will be advertised
2019-07-15 12:02:30.177 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc24: lease 10.0.1.43 will be advertised
----snip----
2019-07-15 12:09:10.367 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc52: lease 10.0.1.43 will be advertised
2019-07-15 12:09:25.919 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc54: lease 10.0.1.43 will be advertised
2019-07-15 12:09:43.482 INFO  [kea-dhcp4.leases/74] DHCP4_LEASE_ADVERT [hwtype=1 50:32:37:85:74:65], cid=[01:50:32:37:85:74:65], tid=0x65fccc56: lease 10.0.1.43 will be advertised

```



Permissions and contents of `usr/local/sbin`:

```
drwxrwxr-x  10 stevejobs  wheel      320 Jun 30 09:21 .
drwxr-xr-x  16 root       wheel      512 Jun 30 08:22 ..
-rwxr--r--   1 stevejobs  admin    21461 Jun 30 09:21 kea-admin
-rwxr--r--   1 stevejobs  admin   445840 Jun 30 09:21 kea-ctrl-agent
-rwxr-xr-x   1 stevejobs  admin   801128 Jun 30 09:21 kea-dhcp-ddns
-rwxr--r--   1 stevejobs  admin  1228276 Jun 30 09:21 kea-dhcp4
-rwxr-xr-x   1 stevejobs  admin  1185736 Jun 30 09:21 kea-dhcp6
-rwxr-xr-x   1 stevejobs  admin   360544 Jun 30 09:21 kea-lfc
-rwxr-xr-x   1 stevejobs  admin    17866 Jun 30 09:21 keactrl
-rwxr-xr-x   1 stevejobs  admin   612768 Jun 30 09:21 perfdhcp
```



Using launchd to start the server and ctrl:

`➜  sbin cat /Library/LaunchDaemons/com.haakonstorm.kea-dhcp4.plist`

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Disabled</key>
	<false/>
	<key>Label</key>
	<string>com.haakonstorm.kea-dhcp4</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/sbin/kea-dhcp4</string>
		<string>-c</string>
		<string>/usr/local/etc/kea/kea-dhcp4.conf</string>
	</array>
	<key>StandardErrorPath</key>
	<string>/tmp/com.haakonstorm.kea-dhcp4.err</string>
	<key>StandardOutPath</key>
	<string>/tmp/com.haakonstorm.kea-dhcp4.out</string>
</dict>
</plist>
```



`➜ sbin cat /Library/LaunchDaemons/com.haakonstorm.kea-ctrl.plist`

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Disabled</key>
	<false/>
	<key>Label</key>
	<string>com.haakonstorm.kea-ctrl-agent</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/sbin/kea-ctrl-agent</string>
		<string>-c</string>
		<string>/usr/local/etc/kea/kea-ctrl-agent.conf</string>
	</array>
	<key>StandardErrorPath</key>
	<string>/tmp/com.haakonstorm.kea-ctrl.err</string>
	<key>StandardOutPath</key>
	<string>/tmp/com.haakonstorm.kea-ctrl.out</string>
</dict>
</plist>
```



--
 Haakon Storm Heen 





More information about the Kea-users mailing list