skleijkers/kea-dhcp4-ha

By skleijkers

Updated about 2 months ago

Kea DHCP 4 server with High Availability module

Image
Networking
1

10K+

skleijkers/kea-dhcp4-ha repository overview

Kea DHCP4 server docker image with high availability addon

This is a Kea DHCP4 server image with the high availability addon baked in. It makes it possible to run multiple Kea DHCP4 servers that can divide or take over each other functions, depending on how it is configured.

The tag number represents the Kea version.

An example configuration is provided, the full documentation regarding the configuration can be found on Kea Documentation.

An example configuration file is also included in the image and copied to the configuration directory if no configuration file is found. The configuration file uses default values and needs to be adjusted for correct operation in a high availability setup.

Install

docker pull skleijkers/kea-dhcp4-ha:latest

Run

docker run --volume "./etc:/etc/kea" \
    --name kea --rm \
    --net=host \
    skleijkers/kea-dhcp4-ha:latest

Docker compose

services:
  kea:
    image: skleijkers/kea-dhcp4-ha:latest
    container_name: kea
    environment:
      - TZ=Europe/Amsterdam
    volumes:
      - ./config:/etc/kea
    networks_mode: host
    restart: unless-stopped

Services

ServicePort
Control (tcp)8000/tcp
DHCP (udp)67/udp

The container can be run in three different modes:

  • Host mode
  • MACVLAN mode
  • Bridge mode
Host mode

The run and compose commands are given for the host mode. In host mode the container will use the host network, so the ip address of the container needs to match with the ip address in the configuration file in the peer part. Further more the interface name in the configuration file needs to match with the interface name of the container. If the control port overlaps with another port on the host it is possible to configure another port for the control server.

MACVLAN mode

In macvlan mode a second MAC address and IP address needs to be configured for the container. This IP address will then be used as the ip address for the DHCP server. In this mode it is possible to use the same ports for other containers or services on the host, without overlapping with the KEA DAHCP server.

Bridge mode

For a DHCP server to work in a bridged network a DHCP relay server needs to be added. This relay server needs to run in host mode and pass the traffic from 67/udp to the DHCP server. As this is a more complex setup and the advantages are limited it is not recommended to use this mode. If you still want to use this mode please check out this thread.

Volumes

VolumeDescription
/etc/keaWhere the kea-dhcp4.conf is placed

Configuration

The configuration file kea-dhcp4.conf should be placed in the /etc/kea volume.

An example configuration file is also included in the image and copied to the configuration directory if no configuration file is found. The configuration file uses default values and needs to be adjusted for correct operation in a high availability setup.

Example configuration

Be aware that the ip address of the container/host (depending on the mode) needs to match with the ip address in the configuration file in the peer part.

{
"Dhcp4": {
    "interfaces-config": {
        "interfaces": [ "eth0" ],
    },
    "lease-database": {
        "type": "memfile",
        "name": "/etc/kea/kea-leases4.csv"
    },
    "valid-lifetime": 28800,

    "control-sockets": [
        {
            "socket-type": "unix",
            "socket-name": "/var/run/kea/kea4-ctrl-socket"
        },
        {
            "socket-type": "http",
            "socket-port": 8000
        }
    ],

    "hooks-libraries": [{
        "library": "/usr/lib/kea/hooks/libdhcp_lease_cmds.so",
        "parameters": { }
    }, {
        "library": "/usr/lib/kea/hooks/libdhcp_ha.so",
        "parameters": {
            "high-availability": [{
                "this-server-name": "server1",
                "mode": "hot-standby",
                "heartbeat-delay": 10000,
                "max-response-delay": 30000,
                "max-ack-delay": 5000,
                "max-unacked-clients": 0,
                "peers": [{
                    "name": "server1",
                    "url": "http://192.168.0.10:8000/",
                    "role": "primary",
                    "auto-failover": true
                }, {
                    "name": "server2",
                    "url": "http://192.168.0.11:8000/",
                    "role": "standby",
                    "auto-failover": true
                }]
            }]
        }
    }],

    "subnet4": [
        {
            "subnet": "192.168.0.0/24",
            "id": 1,
            "interface": "eth0",
            "pools": [
                {
                    "pool": "192.168.0.100-192.168.0.200"
                }
            ],
            "option-data": [
                {
                    "name": "routers",
                    "data": "192.168.0.1"
                },
                {
                    "name": "domain-name-servers",
                    "data": "192.168.0.1"
                },
                {
                    "name": "domain-search",
                    "data": "exmaple.com"
                }
            ]
        }
    ],

    "loggers": [
        {
            "name": "kea-dhcp4",
            "output_options": [
                {
                    "output": "stdout"
                }
            ],
            "severity": "INFO"
        }
    ]
}
}

Tag summary

Content type

Image

Digest

sha256:9d95c10c2

Size

7.9 MB

Last updated

about 2 months ago

docker pull skleijkers/kea-dhcp4-ha