Kea DHCPv4 lease promotion GUI
4.3K
A web-based GUI for promoting KEA DHCP leases to permanent reservations.
lease_cmds - For viewing leaseshost_cmds - For creating/managing reservationsYour KEA server must have the Control Agent running. Add this to your KEA configuration (/etc/kea/kea-ctrl-agent.conf):
{
"Control-agent": {
"http-host": "0.0.0.0",
"http-port": 8000,
"control-sockets": {
"dhcp4": {
"socket-type": "unix",
"socket-name": "/tmp/kea4-ctrl-socket"
}
}
}
}
Both of these libraries are essential for the GUI to work!
Edit your DHCPv4 configuration (/etc/kea/kea-dhcp4.conf) and add both hook libraries:
{
"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_host_cmds.so",
"parameters": {}
}
],
// ... rest of your configuration
}
}
Common hook library paths:
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_*.so/usr/lib64/kea/hooks/libdhcp_*.so/usr/local/lib/kea/hooks/libdhcp_*.so/usr/lib/kea/hooks/libdhcp_*.soAfter modifying the configuration, restart KEA:
sudo systemctl restart kea-dhcp4-server
sudo systemctl restart kea-ctrl-agent
To verify it's working:
curl -X POST -H "Content-Type: application/json" \
-d '{"command": "list-commands", "service": ["dhcp4"]}' \
http://localhost:8000
# You should see these commands:
# - lease4-get-all (from lease_cmds)
# - reservation-add (from host_cmds)
Edit config.yaml with your KEA server details:
kea:
control_agent_url: "http://your-kea-server:8000"
# Optional authentication
username: ""
password: ""
pip install -r requirements.txt
python app.py
Visit:
http://localhost:5000http://localhost:5000/apidocsImportant: You must mount a configuration file for the container to work properly!
# 1. Create a config.yaml file on your host
cat > config.yaml << 'EOF'
kea:
control_agent_url: "https://your-kea-server:8000"
username: "admin"
password: "your-password"
default_subnet_id: 1
app:
host: "0.0.0.0"
port: 5000
debug: false
logging:
level: "INFO"
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
EOF
# 2. Pull the latest image
docker pull awkto/kea-gui-reservations:latest
# 3. Run with your config mounted
docker run -d \
--name kea-gui \
-p 5000:5000 \
-v $(pwd)/config.yaml:/app/config/config.yaml:ro \
awkto/kea-gui-reservations:latest
# 4. Check logs to verify config was loaded
docker logs kea-gui | head -20
# Should see: "✅ Loaded configuration from /app/config/config.yaml"
⚠️ Common Mistake: Forgetting to mount the config file will cause the container to use default settings (localhost), which will fail!
# 1. Clone the repository or create these files:
# - docker-compose.yml
# - config.yaml
# 2. Edit config.yaml with your KEA server details
# 3. Start the container
docker-compose up -d
# 4. View logs
docker-compose logs -f
After starting the container, verify the config was loaded:
# Check config file exists in container
docker exec kea-gui cat /app/config/config.yaml
# Check via API
curl http://localhost:5000/api/config | jq '.config.kea.control_agent_url'
# Check health
curl http://localhost:5000/api/health
Troubleshooting: If you see errors connecting to localhost when you configured a different server, see DOCKER_CONFIG_TROUBLESHOOTING.md
docker build -t kea-gui .
docker run -d -p 5000:5000 -v $(pwd)/config.yaml:/app/config/config.yaml:ro kea-gui
This application includes Swagger/OpenAPI documentation with an interactive API explorer:
📚 Access the API documentation at: http://localhost:5000/apidocs
The Swagger UI provides:
GET /api/health - Health check and KEA connectivity statusGET /api/leases - Fetch all DHCPv4 leases (optional: filter by subnet)GET /api/reservations - List current reservations (optional: filter by subnet)POST /api/reservations - Create a new reservationPOST /api/promote - Promote a lease to permanent reservationDELETE /api/reservation/<ip> - Delete a reservationGET /api/reservations/export - Export all reservations to JSON filePOST /api/reservations/import - Import reservations from JSON fileGET /api/subnets - Get configured DHCP subnetsPOST /api/validate-ip - Validate IP address against subnetGET /api/config - Get current configuration (sanitized)POST /api/config - Save configuration to fileFor detailed documentation including request/response schemas, visit /apidocs when the application is running.
Export Reservations:
Import Reservations:
sample_reservations.json for format)Import File Format: The import file should be a JSON file with this structure:
{
"reservations": [
{
"ip-address": "192.168.1.100",
"hw-address": "aa:bb:cc:dd:ee:01",
"hostname": "device1",
"subnet-id": 1
}
]
}
Or simply an array of reservations:
[
{
"ip-address": "192.168.1.100",
"hw-address": "aa:bb:cc:dd:ee:01",
"hostname": "device1",
"subnet-id": 1
}
]
See sample_reservations.json in the repository for a complete example.
Note: Import failures can occur due to:
The import process will continue even if individual reservations fail, and you'll receive a detailed report at the end.
This app includes a built-in MCP server for AI agent integration (e.g., Claude Code). MCP allows AI assistants to manage DHCP leases and reservations programmatically.
Set the MCP_ENABLED environment variable:
docker run -d -p 5000:5000 \
-e MCP_ENABLED=true \
-v $(pwd)/config.yaml:/app/config/config.yaml:ro \
awkto/kea-gui-reservations:latest
| Endpoint | Description |
|---|---|
GET /mcp/sse | SSE transport (requires Bearer token) |
POST /mcp/messages | JSON-RPC messages (requires Bearer token) |
GET /mcpdocs | Interactive MCP tool documentation |
| Tool | Description |
|---|---|
list_leases | List all active DHCP leases |
list_reservations | List all DHCP reservations |
create_reservation | Create a new reservation |
delete_reservation | Delete a reservation by IP |
promote_lease | Promote a lease to a reservation |
list_subnets | List configured subnets |
delete_lease_by_ip | Delete a lease by IP address |
delete_leases_by_mac | Delete leases by MAC address |
export_reservations | Export reservations to JSON |
import_reservations | Import reservations from JSON |
health_check | Check health and KEA connectivity |
Add to your Claude Code MCP settings:
{
"mcpServers": {
"kea": {
"type": "url",
"url": "https://your-kea-host/mcp/sse",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}
The MCP server uses the same API token as the REST API.
This project includes GitHub Actions for automated Docker image builds. See CICD_SETUP.md for setup instructions.
Docker images are automatically published to Docker Hub on tagged releases.
MIT
Content type
Image
Digest
sha256:6a235e930…
Size
65.1 MB
Last updated
about 2 months ago
docker pull awkto/kea-gui-reservations