DOCFIX-193: LAN DHCP was never implemented -- add Kea to the edge config template
The operator's goal for the Office1 edge was "router + DHCP for office1-local". The
router half works; the DHCP half was NEVER BUILT. The template had no DHCP section at
all -- no <dhcpd>, no <Kea> -- and nothing served DHCP (measured on the live edge: no
kea/dhcpd/dnsmasq process, nothing on udp/67). The ledger's claim of "DHCP .100-.199"
was false; corrected in place.

OPNsense 26.1 uses KEA. ISC dhcpd is gone, so an old-style <dhcpd> block would have been
inert -- which is the trap this could easily have fallen into.

The Kea shape is NOT invented: it mirrors what OPNsense itself PERSISTS on the live 26.1
box (read back from its config.xml, which its own migrations had populated with an
enabled=0 skeleton), and the field names match the upstream model
src/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv4.xml.

Render script now derives and VALIDATES, rather than trusting inputs:
  - LAN_NETWORK_CIDR derived from LAN_IPADDR/LAN_SUBNET_BITS (the subnet must be the
    NETWORK, not the host address -- 10.12.8.1/22 -> 10.12.8.0/22).
  - subnet4 uuid is a DETERMINISTIC uuid5 of the LAN CIDR, so re-rendering is idempotent
    and does not churn the config.
  - DHCP_POOL_START/END are REQUIRED and validated: a pool outside the LAN subnet, a pool
    that swallows the router's own LAN address, or reversed bounds all FAIL LOUD. Each of
    those is XML-valid and would serve nobody (or fight the router) -- exactly the class of
    silent misconfiguration this session has been finding all day.

Harness 15 -> 24 PASS (T10-T13, incl. three negative cases). Gauntlet ALL GREEN (52);
repo-lint 0 fail.

NOT YET APPLIED to the live edge -- that is a separate gated mutation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y117t1F525ba9r1vXSBETk
1 parent d162e7e commit 7a2b3965ced1564ce381c42b69324c8e7c617d83
@JANeumatrix JANeumatrix authored 1 day ago
Showing 3 changed files
View
opentofu/templates/opnsense-config.xml.tmpl
View
scripts/opnsense-render-config.sh
View
tests/opnsense-render-config/run-tests.sh