Kea is ISC’s modern DHCP server, the successor to the venerable ISC DHCP (isc-dhcp-server), which reached end of life in 2022. Kea is configured in JSON, manageable through a REST API, multi-threaded, and has built-in high availability: two servers share the lease state and take over from each other automatically.
Stork is ISC’s web dashboard for Kea. It shows both servers, their HA state, pools and utilisation, leases and reservations, and exports Prometheus metrics.
This guide builds:
- Two Kea DHCPv4 servers,
kea-01andkea-02, in a hot-standby HA pair: lease updates are replicated synchronously, and failover is automatic - HA traffic over a dedicated, multi-threaded HTTPS listener with mutual TLS, independent of the Control Agent
- The Kea Control Agent bound to localhost only, with HTTP basic authentication, so the management API isn’t reachable from the network at all
- One Stork server on its own VM, with PostgreSQL, HTTPS for the web UI, and agents on both Kea servers
- Firewalls, failover tests, maintenance procedures and monitoring
Tested on: Debian 13 “trixie” with Kea 2.6 from the Debian archive and Stork 2.x from ISC’s package repository. All commands run as root. Commands marked (both) run on kea-01 and kea-02.
Table of contents
- Placeholders
- Architecture and versions
- Prerequisites
- Certificates
- Install Kea
- The DHCPv4 configuration with HA
- The Control Agent: localhost only, with authentication
- Start the pair and check HA
- Relays: getting DHCP traffic to both servers
- Stork server
- Stork agents on the Kea servers
- Firewall
- Testing
- Monitoring
- Maintenance and upgrades
- Troubleshooting
- Checklist
1. Placeholders
| Placeholder | Meaning |
|---|---|
kea-01.example.org / 10.20.0.81 | DHCP server 1 (primary) |
kea-02.example.org / 10.20.0.82 | DHCP server 2 (standby) |
stork.example.org / 10.20.0.85 | Stork server |
10.30.0.0/24 | An example client subnet, relayed by its gateway 10.30.0.1 |
10.20.99.0/24 | Admin network (Stork web UI, SSH) |
10.20.99.10 | Prometheus |
2. Architecture and versions
| Component | Version on Debian 13 | Source |
|---|---|---|
| Kea DHCPv4, Control Agent, hooks | 2.6.3 | Debian archive (security-supported) |
| Kea 3.0 | 3.0.x | trixie-backports (see section 15) |
| Stork server and agent | 2.x | ISC’s package repository (not in Debian) |
| PostgreSQL (for Stork) | 17 | Debian archive |
How the pieces talk to each other:
| Connection | Port | Protection |
|---|---|---|
| DHCP clients / relays โ both Kea servers | UDP 67 | Firewall (relay addresses only) |
| kea-01 โ kea-02: HA heartbeats and lease updates | TCP 8001 | Mutual TLS (dedicated HA listener) |
| Stork agent โ local Control Agent | TCP 8000 on 127.0.0.1 | Basic authentication, localhost only |
| Stork server โ Stork agents | TCP 8080 | Mutual TLS with certificates from Stork’s own CA |
| Stork agents โ Stork server | TCP 8443 | HTTPS |
| Admins โ Stork web UI | TCP 8443 | HTTPS |
| Prometheus โ Stork agents (Kea metrics) | TCP 9547 | Firewall (plain HTTP) |
Why hot-standby? In hot-standby, the primary answers every client and the standby only takes over when the primary fails. It’s simple, predictable, and the logs are always on one server. Load-balancing splits clients between both servers and doubles the throughput, but a single modern server already handles thousands of leases per second. Section 6.3 shows the switch if you need it.
Why not a shared lease database? Kea HA is designed for each server to keep its own lease file (
memfile) and replicate updates to its partner. A shared SQL database just moves the single point of failure into the database.
3. Prerequisites
- Two Kea VMs on different hypervisor hosts, with static addresses
- Time synchronised (chrony). Lease times and the HA clock-skew check depend on it, and HA refuses to work above 60 seconds of skew.
- One Stork VM (2 vCPU, 4 GB RAM is plenty)
- Names resolve in both directions
4. Certificates
The two Kea servers authenticate each other for HA with certificates from a small internal CA, and the Stork web UI uses one from the same CA (or a public certificate, if you have one for it). On an admin workstation:
mkdir -p ~/dhcp-ca && cd ~/dhcp-ca
umask 077
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-days 3650 -subj "/CN=DHCP Cluster CA" -keyout ca.key -out ca.crt
issue() { # issue <name> <ip>
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
-subj "/CN=$1.example.org" -keyout "$1.key" -out "$1.csr"
openssl x509 -req -in "$1.csr" -CA ca.crt -CAkey ca.key -CAcreateserial -days 825 -out "$1.crt" \
-extfile <(printf 'subjectAltName=DNS:%s.example.org,DNS:%s,IP:%s\nbasicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature\nextendedKeyUsage=serverAuth,clientAuth\n' "$1" "$1" "$2")
}
issue kea-01 10.20.0.81
issue kea-02 10.20.0.82
issue stork 10.20.0.85
openssl verify -CAfile ca.crt kea-01.crt kea-02.crt stork.crtCode language: PHP (php)
The Kea certificates have both serverAuth and clientAuth: each server is a TLS server (its HA listener) and a TLS client (talking to its partner).
On all three VMs, trust the CA system-wide. The Stork agents verify the Stork server’s certificate against it:
cp ca.crt /usr/local/share/ca-certificates/dhcp-cluster-ca.crt
update-ca-certificates
5. Install Kea
(both)
apt update
apt install kea-dhcp4-server kea-ctrl-agent kea-common
During installation, debconf asks about the Control Agent password. Choose a random password. Debian writes it to /etc/kea/kea-api-password (0640 root:_kea), and kea-ctrl-agent.service refuses to start while that file is empty.
Place the certificates (each server its own pair):
install -d -m 0750 -o root -g _kea /etc/kea/tls
install -m 0644 -o root -g _kea ca.crt /etc/kea/tls/ca.crt
install -m 0644 -o root -g _kea kea-01.crt /etc/kea/tls/server.crt
install -m 0640 -o root -g _kea kea-01.key /etc/kea/tls/server.key
Kea needs the private key unencrypted (as created above), readable by the _kea user that both daemons run as.
| Path | Purpose |
|---|---|
/etc/kea/kea-dhcp4.conf | DHCPv4 server configuration |
/etc/kea/kea-ctrl-agent.conf | Control Agent (REST API) |
/usr/lib/<arch>/kea/hooks/ | Hook libraries (libdhcp_ha.so, libdhcp_lease_cmds.so, libdhcp_stat_cmds.so, …) |
/var/lib/kea/kea-leases4.csv | The lease file |
/run/kea/ | Control sockets |
6. The DHCPv4 configuration with HA
6.1 The configuration
(both) Replace /etc/kea/kea-dhcp4.conf. The file is identical on both servers, except for this-server-name and the interface address. Kea accepts // comments in its JSON.
{
"Dhcp4": {
// --- Interfaces: answer relayed traffic on the server's own address -----------
"interfaces-config": {
"interfaces": [ "ens18/10.20.0.81" ],
"dhcp-socket-type": "udp",
"service-sockets-max-retries": 5,
"service-sockets-retry-wait-time": 5000
},
// --- Control socket for the Control Agent and local tools -----------------------
"control-socket": {
"socket-type": "unix",
"socket-name": "/run/kea/kea4-ctrl-socket"
},
// --- Leases: local CSV file, replicated by HA -----------------------------------
"lease-database": {
"type": "memfile",
"persist": true,
"name": "/var/lib/kea/kea-leases4.csv",
"lfc-interval": 3600
},
// --- Multi-threading: required for the dedicated HA listener --------------------
"multi-threading": {
"enable-multi-threading": true,
"thread-pool-size": 4,
"packet-queue-size": 64
},
// --- Global lease times --------------------------------------------------------------
"valid-lifetime": 7200,
"renew-timer": 1800,
"rebind-timer": 3600,
// --- Hooks ----------------------------------------------------------------------------
"hooks-libraries": [
{ "library": "libdhcp_lease_cmds.so" },
{ "library": "libdhcp_stat_cmds.so" },
{
"library": "libdhcp_ha.so",
"parameters": {
"high-availability": [ {
"this-server-name": "kea-01",
"mode": "hot-standby",
"heartbeat-delay": 10000,
"max-response-delay": 60000,
"max-ack-delay": 5000,
"max-unacked-clients": 5,
"max-rejected-lease-updates": 10,
// Mutual TLS for all HA traffic
"trust-anchor": "/etc/kea/tls/ca.crt",
"cert-file": "/etc/kea/tls/server.crt",
"key-file": "/etc/kea/tls/server.key",
"require-client-certs": true,
// Dedicated multi-threaded HTTPS listener: HA doesn't depend on the Control Agent
"multi-threading": {
"enable-multi-threading": true,
"http-dedicated-listener": true,
"http-listener-threads": 0,
"http-client-threads": 0
},
"peers": [
{
"name": "kea-01",
"url": "https://10.20.0.81:8001/",
"role": "primary",
"auto-failover": true
},
{
"name": "kea-02",
"url": "https://10.20.0.82:8001/",
"role": "standby",
"auto-failover": true
}
]
} ]
}
}
],
// --- Subnets: ALWAYS set explicit, identical IDs on both servers ------------------
"subnet4": [
{
"id": 30,
"subnet": "10.30.0.0/24",
"pools": [ { "pool": "10.30.0.100 - 10.30.0.250" } ],
"option-data": [
{ "name": "routers", "data": "10.30.0.1" },
{ "name": "domain-name-servers", "data": "10.20.0.53, 10.20.0.54" },
{ "name": "domain-name", "data": "example.org" }
],
"reservations": [
{ "hw-address": "52:54:00:aa:bb:cc", "ip-address": "10.30.0.10", "hostname": "printer-01" }
]
}
],
// --- Logging to the journal ----------------------------------------------------------
"loggers": [ {
"name": "kea-dhcp4",
"output-options": [ { "output": "stdout" } ],
"severity": "INFO"
} ]
}
}Code language: JSON / JSON with Comments (json)
On kea-02, change exactly two things: "this-server-name": "kea-02", and the interface to "ens18/10.20.0.82".
6.2 The important settings explained
| Setting | Why |
|---|---|
"interfaces": ["ens18/10.20.0.81"] | Bind to the server’s address on that interface. For relayed DHCP (the normal case in routed networks), that’s all Kea needs. |
lease_cmds hook | Required by HA: the partner uses its commands to push and fetch leases |
stat_cmds hook | Lets Stork show pool utilisation and lease statistics |
mode: hot-standby | The primary serves, the standby receives every lease update and takes over on failure |
heartbeat-delay / max-response-delay | A heartbeat every 10 s. After 60 s without an answer, the partner is suspected down. |
max-unacked-clients: 5 | Before declaring the partner down, the standby also checks whether clients are being ignored. If 5 clients get no answer, the primary is really gone, not just the HA link. That prevents a split-brain when only the link between the servers fails. |
TLS keys + require-client-certs: true | HA traffic only from a peer with a certificate from your CA. Nobody else can inject or read lease updates. |
http-dedicated-listener: true | HA runs its own HTTPS listener on port 8001. The Control Agent isn’t involved, so it can stay on localhost. |
Explicit subnet "id" | Leases reference subnet IDs. If IDs differ between the servers (or change on reordering), replicated leases land in the wrong subnet. Always set them explicitly. |
lfc-interval: 3600 | The lease file cleanup (kea-lfc) compacts the CSV file every hour |
6.3 Load-balancing instead of hot-standby
To use both servers actively, change "mode" to "load-balancing", the roles to "primary" and "secondary", and add "delayed-updates-limit": 100 next to the timers. Kea splits clients between the servers with a hash of their identifiers. Each server handles its half, and takes over the other half when its partner fails. Pools need no changes.
6.4 Validate
kea-dhcp4 -t /etc/kea/kea-dhcp4.conf
The check must end without errors. Kea refuses to start with an invalid file, so always test before you restart.
7. The Control Agent: localhost only, with authentication
The Control Agent (CA) provides Kea’s REST API. It’s how Stork and your tools talk to Kea. Because HA has its own listener, the CA doesn’t need to be reachable from the network: bind it to 127.0.0.1. The Stork agent runs on the same host, so localhost is all it needs.
Create a second password, for Stork. The Stork agent automatically uses a CA user whose name starts with stork:
openssl rand -base64 24 | tr -d '\n' > /etc/kea/stork-api-password
chown root:_kea /etc/kea/stork-api-password
chmod 0640 /etc/kea/stork-api-passwordCode language: JavaScript (javascript)
(both) Replace /etc/kea/kea-ctrl-agent.conf:
{
"Control-agent": {
// Localhost only: the API is never exposed to the network
"http-host": "127.0.0.1",
"http-port": 8000,
"authentication": {
"type": "basic",
"realm": "kea-control-agent",
"directory": "/etc/kea",
"clients": [
{ "user": "kea-api", "password-file": "kea-api-password" },
{ "user": "stork-api", "password-file": "stork-api-password" }
]
},
"control-sockets": {
"dhcp4": {
"socket-type": "unix",
"socket-name": "/run/kea/kea4-ctrl-socket"
}
},
"loggers": [ {
"name": "kea-ctrl-agent",
"output-options": [ { "output": "stdout" } ],
"severity": "INFO"
} ]
}
}Code language: JSON / JSON with Comments (json)
kea-ctrl-agent -t /etc/kea/kea-ctrl-agent.conf
Why no TLS on the Control Agent? It only listens on
127.0.0.1, so the traffic never leaves the machine. Basic authentication protects it against other local users. If you ever bind the CA to a network address (for example, for central automation), addtrust-anchor,cert-file,key-fileandcert-requiredto this file. Kea’s own documentation calls basic auth without TLS weak once it leaves the host.
8. Start the pair and check HA
(both)
systemctl enable --now kea-dhcp4-server kea-ctrl-agent
systemctl status kea-dhcp4-server kea-ctrl-agent --no-pager
journalctl -u kea-dhcp4-server -n 30 --no-pager
Watch the HA state machine in the log: the servers find each other, synchronise their leases (HA_SYNC_SUCCESSFUL), and settle into their roles.
Ask Kea for its HA status through the local Control Agent. This small helper keeps the password off the command line:
kea() {
curl -s -u "kea-api:$(cat /etc/kea/kea-api-password)" \
-H 'Content-Type: application/json' \
-d "{\"command\": \"$1\", \"service\": [\"dhcp4\"]}" \
http://127.0.0.1:8000/ | python3 -m json.tool
}
kea status-getCode language: JavaScript (javascript)
In the high-availability section of the answer:
| Server | Expected state |
|---|---|
| kea-01 (primary) | hot-standby |
| kea-02 (standby) | hot-standby |
Both show hot-standby in a healthy pair: it’s the name of the mode and of the normal operating state. kea-01 serves the clients, and kea-02 receives the lease updates.
9. Relays: getting DHCP traffic to both servers
DHCP clients broadcast, and broadcasts don’t cross routers. The gateway of every client subnet forwards DHCP to the servers as a relay (also called DHCP helper or ip helper-address). Configure both Kea servers as relay targets. Both must receive every request: the active server answers, and the other one needs to see the traffic to notice when its partner stops answering (max-unacked-clients).
Examples:
! Cisco IOS
interface Vlan30
ip helper-address 10.20.0.81
ip helper-address 10.20.0.82Code language: CSS (css)
# MikroTik RouterOS 7
/ip dhcp-relay add name=relay-vlan30 interface=vlan30 \
dhcp-server=10.20.0.81,10.20.0.82 local-address=10.30.0.1 disabled=noCode language: PHP (php)
# Linux (isc-dhcp-relay or the Kea-compatible dhcrelay)
dhcrelay -id vlan30 -iu ens18 10.20.0.81 10.20.0.82Code language: CSS (css)
The relay’s address in the client subnet (10.30.0.1) tells Kea which subnet a request comes from, so it must fall inside a configured subnet4.
10. Stork server
10.1 Install
Stork isn’t in Debian. ISC publishes packages in its own repository on Cloudsmith, which provides a setup script that adds the repository with its signing key. Get the current command from ISC’s Stork download page (Cloudsmith, repository isc/stork). Download the script, read it, then run it, rather than piping it straight into a shell:
curl -1sLf -o /usr/local/src/stork-repo-setup.sh '<setup-script URL from ISC Cloudsmith page>'
less /usr/local/src/stork-repo-setup.sh
bash /usr/local/src/stork-repo-setup.shCode language: HTML, XML (xml)
Then install the server and its database:
apt update
apt install isc-stork-server postgresql
10.2 Database
Stork needs PostgreSQL 10 or later, with the pgcrypto extension (Debian’s PostgreSQL includes it). stork-tool creates the database, the user and the extension, and prints a generated password:
sudo -u postgres stork-tool db-create --db-name stork --db-user stork
# ... note the password it printsCode language: PHP (php)
10.3 Server configuration with HTTPS
Place the Stork certificate:
install -d -m 0750 -o root -g stork-server /etc/stork/tls
install -m 0644 -o root -g stork-server stork.crt /etc/stork/tls/server.crt
install -m 0640 -o root -g stork-server stork.key /etc/stork/tls/server.key
Edit /etc/stork/server.env:
# --- Database (local PostgreSQL) ---------------------------------------------------
STORK_DATABASE_HOST=localhost
STORK_DATABASE_PORT=5432
STORK_DATABASE_NAME=stork
STORK_DATABASE_USER_NAME=stork
STORK_DATABASE_PASSWORD=<password from stork-tool>
# --- Web UI and REST API: HTTPS only -------------------------------------------------
STORK_REST_HOST=10.20.0.85
STORK_REST_PORT=8443
STORK_REST_TLS_CERTIFICATE=/etc/stork/tls/server.crt
STORK_REST_TLS_PRIVATE_KEY=/etc/stork/tls/server.key
STORK_REST_STATIC_FILES_DIR=/usr/share/stork/www
# --- Prometheus metrics of the server itself (optional) ------------------------------
STORK_SERVER_ENABLE_METRICS=trueCode language: PHP (php)
chown root:stork-server /etc/stork/server.env
chmod 0640 /etc/stork/server.env
systemctl enable --now isc-stork-server
journalctl -u isc-stork-server -n 30 --no-pager
On its first start, Stork creates its own internal CA in the database. It uses that CA for the mutual-TLS connections to its agents. That’s separate from your DHCP cluster CA, and fully automatic.
10.4 First login
Open https://stork.example.org:8443 from the admin network. Log in as admin / admin, and change the password immediately: at least 12 characters, with upper and lower case, digits and special characters.
Then:
- Create personal accounts for each admin (role
adminorsuper-admin), andread-onlyaccounts for helpdesk and monitoring users. Don’t share the built-inadmin. - If you have a directory service, configure LDAP or OIDC login (built into Stork 2.7 and later).
Don’t expose Stork to the internet. It’s an administration tool. Keep it on the admin network, or behind a VPN. Its
/metricsendpoint has no authentication, so restrict it to Prometheus with the firewall.
11. Stork agents on the Kea servers
(both) Add the same Cloudsmith repository (section 10.1), then:
apt install isc-stork-agent
The agent reads Kea’s configuration files and the stork-api password file, so it needs to be in the _kea group:
usermod -aG _kea stork-agent
Edit /etc/stork/agent.env (addresses for kea-01):
# Address and port the Stork server connects to (gRPC, mutual TLS with Stork's CA)
STORK_AGENT_HOST=10.20.0.81
STORK_AGENT_PORT=8080
# Where the agent registers
STORK_AGENT_SERVER_URL=https://stork.example.org:8443
# Kea metrics for Prometheus: bind to the server's address, not 0.0.0.0
STORK_AGENT_PROMETHEUS_KEA_EXPORTER_ADDRESS=10.20.0.81
STORK_AGENT_PROMETHEUS_KEA_EXPORTER_PORT=9547Code language: PHP (php)
chmod 0640 /etc/stork/agent.env && chown root:stork-agent /etc/stork/agent.env
systemctl enable --now isc-stork-agent
journalctl -u isc-stork-agent -n 30 --no-pager
# "machine registered" ... "registration completed successfully"Code language: PHP (php)
11.1 Approve the agents
A newly registered agent is not trusted automatically. In Stork, open Services โ Machines โ Unauthorized. For each machine, compare its token with the one on the server:
cat /var/lib/stork-agent/tokens/agent-token.txtCode language: JavaScript (javascript)
If it matches, choose Action โ Authorize. Only then does Stork issue the agent its certificate and start talking to it. The token comparison makes sure the machine you approve is really your Kea server, not someone else who registered first.
After both agents are approved, Stork shows the HA pair under DHCP โ Dashboard and in the services view, including the HA state of both servers.
When all machines are registered, disable new registrations: Configuration โ Settings โ Security โ Enable machine registration off. Switch it on again only while adding machines.
12. Firewall
kea-01 and kea-02 (/etc/nftables.d/kea.nft, shown for kea-01):
destroy table inet kea
table inet kea {
chain input {
type filter hook input priority filter - 10; policy accept;
iif "lo" accept
# DHCP from the relays (and directly attached clients, if any)
udp dport 67 ip saddr { 10.30.0.1 } accept
udp dport 67 counter drop
# HA listener: only from the partner
tcp dport 8001 ip saddr 10.20.0.82 accept
tcp dport 8001 counter drop
# Stork agent (gRPC) from the Stork server; Kea metrics from Prometheus
tcp dport 8080 ip saddr 10.20.0.85 accept
tcp dport 9547 ip saddr 10.20.99.10 accept
tcp dport { 8080, 9547 } counter drop
# Control Agent: never from the network (it only listens on 127.0.0.1 anyway)
tcp dport 8000 counter drop
}
}Code language: PHP (php)
Add every relay address to the udp dport 67 rule. If clients are directly attached to a server’s network (no relay), allow their subnet there too.
stork (/etc/nftables.d/stork.nft):
destroy table inet stork
table inet stork {
chain input {
type filter hook input priority filter - 10; policy accept;
iif "lo" accept
# Web UI and agent registration/REST from admins and the Kea servers
tcp dport 8443 ip saddr { 10.20.99.0/24, 10.20.0.81, 10.20.0.82 } accept
tcp dport 8443 counter drop
# PostgreSQL: local only
tcp dport 5432 counter drop
}
}Code language: PHP (php)
13. Testing
13.1 Leases are replicated
Get a lease on a test client in 10.30.0.0/24 (for example networkctl renew <iface>, or dhclient -v). Then, on both servers:
grep -i '<client-mac>' /var/lib/kea/kea-leases4.csvCode language: JavaScript (javascript)
The lease appears on kea-02 too, within a second.
13.2 Failover
systemctl stop kea-dhcp4-server # on kea-01
journalctl -u kea-dhcp4-server -f # on kea-02Code language: PHP (php)
kea-02 notices the missing heartbeats, then the unanswered clients, and moves to partner-down. From then on it answers all clients. With the timers above, that takes up to about a minute. Renewing clients keep their addresses: kea-02 has every lease.
systemctl start kea-dhcp4-server # on kea-01Code language: PHP (php)
kea-01 comes back, synchronises the leases kea-02 handed out meanwhile, and the pair returns to hot-standby. Stork’s dashboard shows every transition.
13.3 The HA link alone fails
Block TCP 8001 between the servers (nft add rule inet kea input tcp dport 8001 drop on kea-02). Both servers lose the heartbeat. But kea-02 still sees kea-01 answering clients (no unacked clients), so it does not take over. That’s max-unacked-clients preventing a split-brain. Remove the rule afterwards.
13.4 Security checks
# From any other host: the Control Agent isn't reachable
curl -s --connect-timeout 3 http://10.20.0.81:8000/ ; echo "exit=$?" # connection refused / timeout
# The HA listener rejects clients without a certificate from the CA
curl -s --connect-timeout 3 --cacert ca.crt https://10.20.0.81:8001/ ; echo "exit=$?" # TLS handshake failure
# Stork only over HTTPS
curl -sI https://stork.example.org:8443/ | head -n 1 # 200 or a redirect
curl -sI http://stork.example.org:8443/ | head -n 1 # failsCode language: PHP (php)
14. Monitoring
| Source | What to watch |
|---|---|
| Stork dashboard | HA state of both servers, pool utilisation per subnet, recent events |
| Kea metrics (Stork agent, port 9547) | Address utilisation, declined addresses, packets received and sent, HA state |
Stork server metrics (/metrics on 8443, if enabled) | Machines and services that are unreachable |
| The journal | journalctl -u kea-dhcp4-server for HA state changes and pool exhaustion |
Prometheus alerts worth having, built on the Kea exporter’s metrics (check the exact metric names with curl -s http://10.20.0.81:9547/metrics | grep -i -E 'addresses|ha' on your version):
- Pool nearly exhausted: assigned addresses above 90% of the pool size, per subnet.
- HA not in a normal state: any state other than
hot-standby(orload-balancing) for more than 5 minutes.partner-downmeans you’re running without redundancy. - A server unreachable: a scrape of either agent failing.
15. Maintenance and upgrades
15.1 Planned maintenance on one server
Kea has commands for exactly this. Tell the server you’re about to take down to hand over cleanly:
kea ha-maintenance-start # on the server that stays up: puts the partner into maintenanceCode language: PHP (php)
The partner moves to in-maintenance and the remaining server to partner-in-maintenance, which means it serves all clients. Patch and reboot the server in maintenance, then:
kea ha-maintenance-cancel # on the same server, once the patched one is backCode language: PHP (php)
15.2 Configuration changes
- Edit
kea-dhcp4.confon both servers. Keep them identical apart fromthis-server-nameand the interface address. Version them in Git. - Validate with
kea-dhcp4 -t /etc/kea/kea-dhcp4.conf. - Apply without a restart, one server at a time:
kea config-reload.
15.3 Upgrades
Kea 2.6 from the Debian archive is patched by unattended-upgrades (see my unattended-upgrades post). Stagger the reboot windows so both servers never restart together. The HA pair rides out one server at a time. Both servers should run the same Kea version: apply updates to both within the same maintenance window.
Kea 3.0 is available in trixie-backports. Its most important changes:
- The DHCP servers can serve the REST API over HTTPS themselves, so the separate Control Agent becomes unnecessary (and is deprecated).
- Most hook libraries are open source, including host reservation and subnet management commands that Stork can use for editing.
- Stricter checks on file paths and permissions.
Plan a move to 3.0 as its own project: test it in a lab, upgrade both servers in one window, and check that your Stork version supports it first.
15.4 Backups
- Configuration:
/etc/kea/and/etc/stork/, in Git or your configuration management, plus the CA. - Leases: both servers hold the full set, so HA is the redundancy. A nightly copy of
/var/lib/kea/kea-leases4.csvhelps for investigations. - Stork:
pg_dump storknightly. It contains users, settings and Stork’s internal CA.
16. Troubleshooting
| Symptom | Cause / fix |
|---|---|
kea-ctrl-agent.service doesn’t start, with no log | /etc/kea/kea-api-password is empty or missing. The Debian unit has ConditionFileNotEmpty on it. |
HA stays in waiting or syncing | The partner is unreachable on 8001 (firewall), or the TLS handshake fails (wrong CA, missing clientAuth, the IP not in the SAN). Check journalctl -u kea-dhcp4-server. |
| HA log: clock skew too high | The servers’ clocks differ by more than 60 seconds. Fix time sync. |
| Leases go to the wrong subnet after replication | Subnet IDs differ between the servers. Set explicit, identical "id" values. |
Clients get no address, and the log shows no subnet selected | The relay’s address isn’t inside any subnet4, or the relay doesn’t forward to this server |
| Both servers answer clients (split-brain) | Both are in partner-down. Usually the HA link was cut and max-unacked-clients was set to 0. Keep it above 0, and make sure both servers see client traffic (relays to both). |
Stork agent: cannot read credentials | The stork-agent user isn’t in the _kea group, or the password file isn’t group-readable |
| Stork agent registration fails with a TLS error | The DHCP cluster CA isn’t in the Kea server’s trust store (update-ca-certificates), or STORK_AGENT_SERVER_URL uses a name not in Stork’s certificate |
| Machine stays “Unauthorized” | Not approved yet in Services โ Machines (section 11.1) |
AppArmor denials in journalctl -k | Debian ships an AppArmor profile for kea-dhcp4. If it blocks a path you added (certificates elsewhere, custom lease file), keep the files under /etc/kea/ and /var/lib/kea/, or extend the profile in /etc/apparmor.d/local/. |
17. Checklist
- โ Two Kea servers on separate hypervisor hosts, with synchronised time
- โ Kea 2.6 from the Debian archive, with
lease_cmds,stat_cmdsandhahooks loaded - โ
kea-dhcp4.confidentical on both servers apart fromthis-server-nameand the interface, explicit subnet IDs, and versioned in Git - โ HA hot-standby (or load-balancing),
max-unacked-clients> 0, dedicated HTTPS listener with mutual TLS - โ The Control Agent listens on 127.0.0.1 only, with basic auth (
kea-api,stork-api) from0640 root:_keafiles - โ Relays forward to both servers
- โ Stork on its own VM: PostgreSQL, HTTPS on 8443, default
adminpassword changed, personal accounts (and LDAP/OIDC if available) - โ Both agents approved after comparing tokens, and machine registration disabled afterwards
- โ Firewalls: DHCP only from relays, 8001 only between the partners, 8080 only from Stork, 9547 only from Prometheus, Stork UI only from the admin network
- โ Failover, failback, HA-link failure (no split-brain) and the security checks all tested
- โ Monitoring for pool utilisation, HA state and agent reachability
- โ Maintenance via
ha-maintenance-start/ha-maintenance-cancel, staggered reboots, and a plan for Kea 3.0