A web-based GUI for promoting KEA DHCP leases to permanent reservations.
- Connect to KEA DHCP server via Control Agent API
- View active DHCPv4 leases
- Promote leases to permanent reservations with a single click
- Import/Export DHCP reservations - Backup and restore reservations easily
- Simple, intuitive web interface
- Backend: Python Flask application
- Frontend: HTML/JavaScript with Bootstrap
- KEA Integration: KEA Control Agent REST API
- Deployment: Docker container
- KEA DHCP server with Control Agent enabled
- KEA Hook Libraries (required):
lease_cmds- For viewing leaseshost_cmds- For creating/managing reservations
- Docker (for containerized deployment)
Your 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:
- Debian/Ubuntu:
/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_*.so - CentOS/RHEL:
/usr/lib64/kea/hooks/libdhcp_*.so - FreeBSD:
/usr/local/lib/kea/hooks/libdhcp_*.so - Alpine Linux:
/usr/lib/kea/hooks/libdhcp_*.so
After modifying the configuration, restart KEA:
sudo systemctl restart kea-dhcp4-server
sudo systemctl restart kea-ctrl-agentTo 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.pyVisit:
- Web UI:
http://localhost:5000 - API Documentation:
http://localhost:5000/apidocs
Important: 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"# 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 -fAfter 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/healthTroubleshooting: 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-guiThis application includes Swagger/OpenAPI documentation with an interactive API explorer:
๐ Access the API documentation at: http://localhost:5000/apidocs
The Swagger UI provides:
- Complete API reference with request/response schemas
- Interactive "Try it out" functionality to test endpoints directly
- Example requests and responses for each endpoint
- Parameter descriptions and validation rules
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 file
For detailed documentation including request/response schemas, visit /apidocs when the application is running.
- Access the web interface
- View the list of active DHCP leases
- Click "Promote" next to any lease
- Confirm the action
- The lease is converted to a permanent reservation in KEA
Export Reservations:
- Click the "Import/Export" dropdown button
- Select "Export Reservations"
- A JSON file will be downloaded to your machine containing all current reservations
- You can optionally filter by subnet before exporting
Import Reservations:
- Click the "Import/Export" dropdown button
- Select "Import Reservations"
- Choose a JSON file from your computer (see
sample_reservations.jsonfor format) - Click "Import" to begin the process
- The system will:
- Process each reservation one by one
- Continue importing even if individual reservations fail
- Display a summary showing:
- Number of successfully imported reservations
- Number of failed imports
- Details of any failures (duplicate IPs, subnet mismatches, etc.)
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:
- Duplicate IP addresses (reservation already exists)
- IP addresses outside the subnet range
- Invalid MAC addresses
- Missing required fields
The import process will continue even if individual reservations fail, and you'll receive a detailed report at the end.
- Use HTTPS in production
- Secure your KEA Control Agent with authentication
- Run container with appropriate user permissions
- Consider network isolation
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