zoraxy-dhcp/README.md

6 KiB

DHCP Lease Manager

Zoraxy plugin — Manage dnsmasq DHCP leases, assign static IPs, and create network-wide hostnames from the Zoraxy web UI.


Quick Install

curl -sSL https://git.lohmar.co.uk/cclohmar/zoraxy-dhcp/raw/branch/main/install.sh | sudo bash

The installer is fully interactive — it asks for your network settings and then installs everything.

What it sets up:

  • dnsmasq DHCP + DNS server with NAT/routing
  • dhcp-lease-manager plugin inside Zoraxy
  • Group-based permissions for secure config access
  • Linux capabilities (CAP_SYS_ADMIN) for dnsmasq reloads

After installation, open Zoraxy → Plugins → enable DHCP Lease Manager → access at /plugin.ui/dhcp-lease-manager/.


Features

Feature Description
View leases Active DHCP leases with hostname, IP, MAC, expiry
Pin leases Make a lease permanent — sets static DHCP and optional DNS name
DNS names When pinning, give the device a hostname (e.g. printer.lan) — resolves network-wide via dnsmasq DNS
Unpin leases Remove static DHCP assignment and DNS record
Reload Apply changes + scrub expired leases from the lease file
Status badges Green "permanent" / grey "active" indicators

DNS Name Service

When you pin a lease with a hostname, the plugin writes an address=/name/IP record to dnsmasq's config. Every DHCP client using this server for DNS can then resolve the name:

# Before pinning
$ nslookup printer.lan          # → NXDOMAIN

# Click Pin, enter "printer.lan"
$ nslookup printer.lan 10.1.0.10  # → 10.1.0.50 ✓

No extra configuration needed — dnsmasq serves the records automatically on reload. Unpinning removes both the static DHCP assignment and the DNS record.


Requirements

Component Detail
Zoraxy v3.2.0+ (plugin system required)
OS Debian, Ubuntu, RHEL, Fedora, Alpine, Arch
dnsmasq Installed by the script
Go Installed by the script (for building the plugin)
Permissions Script must run as root

Architecture

┌──────────────────────────────────────────────────┐
│                   Zoraxy UI                       │
│  /plugin.ui/dhcp-lease-manager/  ─────► iframe    │
└───────────────────────┬──────────────────────────┘
                        │ reverse proxy
┌───────────────────────▼──────────────────────────┐
│              dhcp-lease-manager                   │
│  Go binary  •  PluginUiRouter  •  JSON API        │
│  Reads/writes config + triggers dnsmasq reload    │
└──────┬────────────────────────────────┬──────────┘
       │ read/write                     │ systemctl reload
┌──────▼──────────────┐    ┌────────────▼──────────┐
│  /opt/zoraxy/       │    │      dnsmasq           │
│  conf/dhcp/         │    │  DHCP: 10.1.0.100-150  │
│  dnsmasq.conf   ────┼────►  DNS:  address=/name/  │
│  dnsmasq.leases     │    │  NAT:  MASQUERADE      │
└─────────────────────┘    └───────────────────────┘
       ▲                              │
       │     DNS queries              ▼
       │   "printer.lan?"     ┌──────────────┐
       └──────────────────────┤ DHCP clients  │
                10.1.0.50     └──────────────┘

All DHCP + DNS configuration lives under /opt/zoraxy/conf/dhcp/ — a single, unified location regardless of whether Zoraxy runs bare-metal or in Docker.


API Endpoints

Method Path Purpose
GET /ui/api/leases List all active + permanent leases
POST /ui/api/pin Pin a lease — set static IP + optional DNS name (body: mac, ip, hostname)
POST /ui/api/unpin Unpin a lease — removes static IP + DNS record (body: mac)
POST /ui/api/reload Reload dnsmasq + scrub expired leases (rate-limited: 5s cooldown)

Environment Variables

Overridable defaults for custom deployments:

Variable Default
LEASE_FILE /opt/zoraxy/conf/dhcp/dnsmasq.leases
CONF_FILE /opt/zoraxy/conf/dhcp/dnsmasq.conf
RELOAD_CMD /usr/bin/systemctl
RELOAD_ARGS reload dnsmasq

Permissions

The installer creates a dnsmasq-edit group for config file access and adds CAP_SYS_ADMIN to the Zoraxy systemd service so the plugin can reload dnsmasq without sudo:

Group: dnsmasq-edit
  → zoraxy user added
  → Read/write on /opt/zoraxy/conf/dhcp/

Zoraxy systemd service:
  → CapabilityBoundingSet=CAP_SYS_ADMIN
  → AmbientCapabilities=CAP_SYS_ADMIN

Uninstall

sudo bash install.sh --remove

Removes dnsmasq, the plugin, config files, group, and NAT rules — leaving the system clean.


Manual Install

# 1. Clone the repo
git clone https://git.lohmar.co.uk/cclohmar/zoraxy-dhcp.git /opt/zoraxy/plugins/dhcp-lease-manager

# 2. Build
cd /opt/zoraxy/plugins/dhcp-lease-manager
go build -buildvcs=false -o dhcp-lease-manager .

# 3. Run setup (as root)
sudo bash install.sh

License

Zoraxy plugin SDK is LGPL. This plugin is open source.


Credits

  • Zoraxy — Reverse proxy and plugin system
  • dnsmasq — DNS/DHCP server