コンテンツにスキップ

kea

https://www.isc.org/kea/

Ubuntu

API

$ sudo apt install kea-ctrl-agent
$ dpkg -L kea-common | grep hooks
/usr/lib/x86_64-linux-gnu/kea/hooks
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_ha.so
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_lease_cmds.so
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_mysql_cb.so
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_stat_cmds.so
/usr/lib/x86_64-linux-gnu/libkea-hooks.so.7.0.3
/usr/lib/x86_64-linux-gnu/libkea-hooks.so.7
$ cat /etc/kea/kea-dhcp4.conf 
{
    "Dhcp4": {
        ...
        "hooks-libraries": [
            {
                "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_lease_cmds.so",
                "parameters": { }
            }
        ]
    }
}
$ sudo systemctl restart kea-dhcp4-server

example: "command": "lease4-get-all"

$ curl -s -H"Content-Type:application/json" http://localhost:8000 -d '{"command": "lease4-get-all","service":["dhcp4"]}' | jq .
[
  {
    "arguments": {
      "leases": [
        {
          "client-id": "01:34:97:f6:7c:ce:96",
          "cltt": 1617352399,
          "fqdn-fwd": true,
          "fqdn-rev": true,
          "hostname": "android-63d1a27d8db517c8",
          "hw-address": "34:97:f6:7c:ce:96",
          "ip-address": "192.168.122.129",
          "state": 0,
          "subnet-id": 1,
          "valid-lft": 3600
        },
        {
                ...
        }
      ]
    },
    "result": 0,
    "text": "11 IPv4 lease(s) found."
  }
]

HA logs

configuration diff

{
    "Dhcp4": {
    ...
        "hooks-libraries": [
            {
                "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_lease_cmds.so",
                "parameters": { }
            },
            {
                "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_ha.so",
                "parameters": {
                    "high-availability": [ {
                        "this-server-name": "noriko",
                        "mode": "hot-standby",
                        "heartbeat-delay": 10000,
                        "max-response-delay": 10000,
                        "max-ack-delay": 5000,
                        "max-unacked-clients": 5,
                        "peers": [
                            {
                                "name": "noriko",
                                "url": "http://192.168.122.35:8000/",
                                "role": "primary",
                                "auto-failover": true
                            },                            {
                                "name": "tokiko",
                                "url": "http://192.168.122.36:8000/",
                                "role": "standby",
                                "auto-failover": true
                            }                        ]
                    } ]
                }
            }
      ...

HA log

# grep "ha-hook" /var/log/kea/kea-dhcp4.log
2021-04-05 18:58:15.398 INFO  [kea-dhcp4.ha-hooks/4020] HA_CONFIGURATION_SUCCESSFUL HA hook library has been successfully configured
2021-04-05 18:58:15.398 INFO  [kea-dhcp4.ha-hooks/4020] HA_INIT_OK loading High Availability hooks library successful
2021-04-05 18:58:15.409 INFO  [kea-dhcp4.ha-hooks/4020] HA_LOCAL_DHCP_DISABLE local DHCP service is disabled while the tokiko is in the WAITING state
2021-04-05 18:58:15.409 INFO  [kea-dhcp4.ha-hooks/4020] HA_SERVICE_STARTED started high availability service in hot-standby mode as standby server
2021-04-05 18:58:26.834 INFO  [kea-dhcp4.ha-hooks/4020] HA_STATE_TRANSITION server transitions from WAITING to SYNCING state, partner state is PARTNER-DOWN
2021-04-05 18:58:26.834 INFO  [kea-dhcp4.ha-hooks/4020] HA_LEASE_UPDATES_DISABLED lease updates will not be sent to the partner while in SYNCING state
2021-04-05 18:58:26.834 INFO  [kea-dhcp4.ha-hooks/4020] HA_SYNC_START starting lease database synchronization with noriko
2021-04-05 18:58:26.837 INFO  [kea-dhcp4.ha-hooks/4020] HA_LEASES_SYNC_LEASE_PAGE_RECEIVED received 12 leases from noriko
2021-04-05 18:58:26.838 INFO  [kea-dhcp4.ha-hooks/4020] HA_SYNC_SUCCESSFUL lease database synchronization with noriko completed successfully in 4.013 ms
2021-04-05 18:58:26.838 INFO  [kea-dhcp4.ha-hooks/4020] HA_STATE_TRANSITION server transitions from SYNCING to READY state, partner state is PARTNER-DOWN
2021-04-05 18:58:26.839 INFO  [kea-dhcp4.ha-hooks/4020] HA_LEASE_UPDATES_DISABLED lease updates will not be sent to the partner while in READY state
2021-04-05 18:58:36.852 INFO  [kea-dhcp4.ha-hooks/4020] HA_STATE_TRANSITION server transitions from READY to HOT-STANDBY state, partner state is HOT-STANDBY
2021-04-05 18:58:36.852 INFO  [kea-dhcp4.ha-hooks/4020] HA_LEASE_UPDATES_ENABLED lease updates will be sent to the partner while in HOT-STANDBY state
2021-04-05 18:58:36.852 INFO  [kea-dhcp4.ha-hooks/4020] HA_LOCAL_DHCP_ENABLE local DHCP service is enabled while the tokiko is in the HOT-STANDBY state

API check ha-heartbeat

$ curl -s -H "Content-Type:application/json" http://192.168.122.35:8000 -d '{"command": "ha-heartbeat","service": ["dhcp4"]}' | jq
[
  {
    "arguments": {
      "date-time": "Mon, 05 Apr 2021 10:04:06 GMT",
      "state": "hot-standby"
    },
    "result": 0,
    "text": "HA peer status returned."
  }
]
$ curl -s -H "Content-Type:application/json" http://192.168.122.36:8000 -d '{"command": "ha-heartbeat","service": ["dhcp4"]}' | jq
[
  {
    "arguments": {
      "date-time": "Mon, 05 Apr 2021 10:04:11 GMT",
      "state": "hot-standby"
    },
    "result": 0,
    "text": "HA peer status returned."
  }
]

FreeBSD

# pkg install kea
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01    
Fetching packagesite.txz: 100%    6 MiB   6.2MB/s    00:01    
Processing entries: 100%
FreeBSD repository update completed. 30622 packages processed.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        boost-libs: 1.72.0_2
        kea: 1.8.0_1
        log4cplus: 1.1.2_3

Number of packages to be installed: 3

The process will require 225 MiB more space.
19 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/3] Fetching kea-1.8.0_1.txz: 100%    6 MiB   6.2MB/s    00:01    
[2/3] Fetching log4cplus-1.1.2_3.txz: 100%  331 KiB 339.2kB/s    00:01    
[3/3] Fetching boost-libs-1.72.0_2.txz: 100%   13 MiB  13.1MB/s    00:01    
Checking integrity... done (0 conflicting)
[1/3] Installing log4cplus-1.1.2_3...
[1/3] Extracting log4cplus-1.1.2_3: 100%
[2/3] Installing boost-libs-1.72.0_2...
[2/3] Extracting boost-libs-1.72.0_2: 100%
[3/3] Installing kea-1.8.0_1...
[3/3] Extracting kea-1.8.0_1: 100%
=====
Message from boost-libs-1.72.0_2:

--
You have built the Boost library with thread support.

Don't forget to add -pthread to your linker options when
linking your code.

最終更新日: 2021-05-16 14:50:48