fix(dhcp): order Kea D2 DNS servers local-first so DDNS stays on-host #87

Merged
charles merged 1 commit from fix/ddns-local-first-server-order into main 2026-08-02 18:44:53 +00:00
Owner

Fixes the live error: DHCP_DDNS ... timed out waiting for response to forward RR removal for roborock-vacuum-a70.home.forked.io. to DNS server 172.16.0.3 port:5300 on octet-dhcp-1.

Root cause: Kea D2 tries a domain's DNS servers in list order, but the list was a plain alphabetical IP sort. Each mesh host owns a distinct lattice /24 (.7 → 172.16.1.0/24, .9 → 172.16.0.0/24), so 172.16.0.3 (dns-3 on .9) always sorted ahead of 172.16.1.4 (dns-1, co-located with dhcp-1 on .7). Every DDNS update from dhcp-1 therefore crossed the mesh to .9 first; when that cross-host round-trip dropped a packet, Kea hit the 2.5s dns-server-timeout and logged the error before falling back to the local dns-1.

Fix: order the D2 dns-servers list local-first — DNS members sharing the DHCP consumer's mesh_host_id come first, each group sorted so the hashed Kea payload stays deterministic. Applies to both the flat ddnsServers and the per-zone ddnsServersByZone. Missing consumer host falls back to the prior plain sort.

Tests: new unit tests for the ordering (local-first, per-group sort, dedupe, no-host fallback); existing dhcp-config determinism test still green.

Takes effect on the next D2 config push after deploy.

🤖 Generated with Claude Code

**Fixes the live error:** `DHCP_DDNS ... timed out waiting for response to forward RR removal for roborock-vacuum-a70.home.forked.io. to DNS server 172.16.0.3 port:5300` on octet-dhcp-1. **Root cause:** Kea D2 tries a domain's DNS servers in list order, but the list was a plain alphabetical IP sort. Each mesh host owns a distinct lattice /24 (.7 → 172.16.1.0/24, .9 → 172.16.0.0/24), so `172.16.0.3` (dns-3 on .9) always sorted ahead of `172.16.1.4` (dns-1, co-located with dhcp-1 on .7). Every DDNS update from dhcp-1 therefore crossed the mesh to .9 first; when that cross-host round-trip dropped a packet, Kea hit the 2.5s dns-server-timeout and logged the error before falling back to the local dns-1. **Fix:** order the D2 `dns-servers` list **local-first** — DNS members sharing the DHCP consumer's `mesh_host_id` come first, each group sorted so the hashed Kea payload stays deterministic. Applies to both the flat `ddnsServers` and the per-zone `ddnsServersByZone`. Missing consumer host falls back to the prior plain sort. **Tests:** new unit tests for the ordering (local-first, per-group sort, dedupe, no-host fallback); existing dhcp-config determinism test still green. Takes effect on the next D2 config push after deploy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kea D2 tries the DNS servers for a DDNS domain in list order, but the list was
a plain alphabetical IP sort. Each mesh host owns a distinct lattice /24
(.7 → 172.16.1.0/24, .9 → 172.16.0.0/24), so 172.16.0.3 (a DNS member on .9)
always sorted ahead of 172.16.1.4 (the DNS member co-located with a DHCP member
on .7). Result: dhcp-1 on .7 forwarded every DDNS update cross-host to dns-3 on
.9 first, and when that cross-host round-trip dropped a packet Kea logged
`timed out waiting for response to forward RR ... to DNS server 172.16.0.3`
before falling back to the local dns-1 — noisy and ~2.5s slower per update.

Order the D2 dns-servers list local-first: DNS members sharing the DHCP
consumer's mesh_host_id come first, each group sorted so the hashed Kea payload
stays deterministic. Applies to both the flat `ddnsServers` and the per-zone
`ddnsServersByZone`. No locality info (missing consumer host) falls back to the
prior plain sort.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/projectoctet!87
No description provided.