routeros: client VLANs resolve via the c1 recursor (gated, lock deferred) #163

Merged
ginjiruu merged 1 commit from dns-client-recursor into master 2026-11-19 14:19:08 +00:00
Owner

Client VLANs get the c1 recursor (10.30.100.53) over DHCP, gated on the recursor answering from each router. Step 1 of the client cutover in lab/clusters#1673. Do not merge unattended: client DNS fails closed.

Router changes per network

Network DHCP DNS Firewall
10 mgmt, 40 iot, 50 guest 10.30.100.53 new accept: zone -> 10.30.100.53 udp/tcp 53
30 trusted 10.30.100.53 none (trusted already reaches everything)
1 legacy LAN (mini-01) stays 8.8.8.8, 1.1.1.1 none
20 servers stays public none

The routers' own resolver (routeros_ip_dns: NTP, the hairpin public_names) stays public.

The legacy LAN stays public on purpose. mini runs the tofu-controller that applies router changes, so with mini on the recursor a recursor failure could block the apply that fixes it (lab/iac#50).

Resolver gate and rollback probe

  • modules/router/dns.tf: a netwatch dns probe resolver-gate on each router asks 10.30.100.53 for resolver.caosh.int.animeteamspeak.moe. terraform_data.resolver_gate runs scripts/resolver-gate.sh, which polls /rest/tool/netwatch until the probe reports up (120 s timeout). The provider fork hides netwatch status (MetaSkipFields), so a precondition can't read it. The script uses the same REST and netrc pattern as rollback/arm.sh, and the password comes from ROUTEROS_PASSWORD in the runner environment.
  • The DHCP networks and the firewall rules depend on the gate, so a dead recursor fails the apply before anything client-facing changes. The gate is tainted, and the controller's next apply retries it.
  • The gate re-runs only when the servers, the probe name or the switched networks change. A recursor outage later does not block unrelated router applies (sim case 4a).
  • rb5009-*/rollback.tf gets a recursor probe. If the recursor dies inside the rollback window after an apply, the judge restores the backup. The probe only counts when it was up at arm time, so a recursor that is already down does not block a router fix.

Not in this PR: the DNS lock

The lock (drop 53/853 udp+tcp to the WAN from the switched CIDRs) is in the code behind client_dns_lock = false in modules/site. Shipping it with the switch would cut DNS for every client still on an old lease: lease time is 1d, so they renew at about 12 h and keep 8.8.8.8 until then. Flip it in a one-line follow-up PR at least a day after this one applied on both routers.

The lock matches source CIDRs, not ZONE-TRUSTED, because the legacy LAN shares that zone. DoH stays possible.

IPv6

No change. There is no WAN v6 (ipv6.tf), so there is no public v6 DNS path to lock. The RAs carry no RDNSS: the routers have no v6 resolvers to advertise, and arch-ws on VLAN 30 shows no IP6.DNS today.

Sim results, 2026-11-19

routeros/sim on the containerlab pair r1/r2 with the harness OpenBao.

Fixtures beyond the committed sim root:

  • A VLAN 20 container at 10.30.20.53 runs dnsmasq on 10.30.100.53 in place of the recursor. routeros/sim routes 10.30.100.0/24 to it in place of c1's BGP route.
  • DHCP clients on VLAN 40 and VLAN 1 (veths on the lab bridge), and the lab client on VLAN 30.
  • The isp CHR answers DNS on 100.64.0.1 and plays the public resolver on the WAN. The lab has no internet, so 8.8.8.8 itself can't be tested. The lock rules match the port and the WAN interface list and ignore the destination address, so the isp listener exercises them the same way.
Case Result
baseline (master) 308 resources applied, second plan empty; every client gets 8.8.8.8 1.1.1.1
A: route only, today's firewall iot -> recursor: no answer (finding 1 reproduced); trusted and legacy LAN answer
1: stand-in down plan: 16 add, 10 change (DHCP 10/30/40/50 only, allows, move, probe, gate). Gate: down for 120 s, exit 1. 0 changes on the routers besides the probe; all DHCP networks still public; gate tainted, next plan replaces it
2: stand-in up gate up after 5 s, apply complete. Leases: VLAN 40 and 30 10.30.100.53, VLAN 1 8.8.8.8 1.1.1.1. iot -> recursor udp+tcp answers; WAN DNS still answers everywhere (no lock)
5: second plan empty
3: lock on (-var client_dns_lock=true) 8 rules per router, ordered after fw-dnat, before fw-trusted. iot and trusted -> WAN DNS udp+tcp: no answer; ICMP to the WAN still passes; legacy LAN -> WAN DNS answers; recursor answers everywhere. Second plan empty
4a: stand-in killed after the apply both routers' resolver-gate probe goes down; the next plan is empty (no gate re-run, applies not blocked)
4b: rollback (sim/rollback/run.sh g, new) the arm's baseline is [anchor peer peer-web recursor]; dnsmasq stopped inside the 180 s window; the judge loaded the backup 6 s after the fire time; the change's route is gone and the rolled-back- marker is written: PASS

The new lock rules took effect about 2-3 s after the apply returned. In a timestamped loop, one query in that window got an answer and every later one was dropped. A gap in that direction only lets DNS through.

Two first-run misses in the sim log came from the fixture, not the change: dnsmasq didn't restart (log file permissions), so the gate correctly refused a second time; and one UDP query timed out right after a client's lease renewal.

task routeros:validate (all three device roots), routeros:guard, tofu fmt -check, and shellcheck on both scripts all pass.

Not proven

  • A plan of the real roots. The router roots are not in the branch planner (#97), and I did not run a local plan with production credentials. The sim root instantiates the same modules.
  • The production rollback window with a real RB5009 reboot (unchanged from #74).

Rollout (human awake)

  1. Merge. Watch routeros-rb5009-a, then -b on mini (approvePlan auto; never both at once). Each runner log should show resolver-gate[...] probe resolver-gate: up.
  2. On a VLAN 30 or 40 device that is not arch-ws (arch-ws resolves via Tailscale): renew DHCP, check the resolver is 10.30.100.53, then dig resolver.caosh.int.animeteamspeak.moe.
  3. Rollback: revert this PR. The gate holds the switch while the recursor is down, and the judge covers a failure inside the window.
  4. After at least one lease time on both routers: the follow-up PR with client_dns_lock = true, then check that dig @8.8.8.8 example.com times out from VLAN 30.

Docs: ADR-0008 rule amended (dated), docs/routeros/README.md "Client DNS", docs/routeros/rollback.md scenario G.

Client VLANs get the c1 recursor (10.30.100.53) over DHCP, gated on the recursor answering from each router. Step 1 of the client cutover in lab/clusters#1673. Do not merge unattended: client DNS fails closed. ## Router changes per network | Network | DHCP DNS | Firewall | |---|---|---| | 10 mgmt, 40 iot, 50 guest | `10.30.100.53` | new accept: zone -> `10.30.100.53` udp/tcp 53 | | 30 trusted | `10.30.100.53` | none (trusted already reaches everything) | | 1 legacy LAN (mini-01) | stays `8.8.8.8, 1.1.1.1` | none | | 20 servers | stays public | none | The routers' own resolver (`routeros_ip_dns`: NTP, the hairpin `public_names`) stays public. The legacy LAN stays public on purpose. mini runs the tofu-controller that applies router changes, so with mini on the recursor a recursor failure could block the apply that fixes it (lab/iac#50). ## Resolver gate and rollback probe - `modules/router/dns.tf`: a netwatch dns probe `resolver-gate` on each router asks `10.30.100.53` for `resolver.caosh.int.animeteamspeak.moe`. `terraform_data.resolver_gate` runs `scripts/resolver-gate.sh`, which polls `/rest/tool/netwatch` until the probe reports `up` (120 s timeout). The provider fork hides netwatch `status` (`MetaSkipFields`), so a precondition can't read it. The script uses the same REST and netrc pattern as `rollback/arm.sh`, and the password comes from `ROUTEROS_PASSWORD` in the runner environment. - The DHCP networks **and the firewall rules** depend on the gate, so a dead recursor fails the apply before anything client-facing changes. The gate is tainted, and the controller's next apply retries it. - The gate re-runs only when the servers, the probe name or the switched networks change. A recursor outage later does not block unrelated router applies (sim case 4a). - `rb5009-*/rollback.tf` gets a `recursor` probe. If the recursor dies inside the rollback window after an apply, the judge restores the backup. The probe only counts when it was up at arm time, so a recursor that is already down does not block a router fix. ## Not in this PR: the DNS lock The lock (drop 53/853 udp+tcp to the WAN from the switched CIDRs) is in the code behind `client_dns_lock = false` in `modules/site`. Shipping it with the switch would cut DNS for every client still on an old lease: lease time is 1d, so they renew at about 12 h and keep `8.8.8.8` until then. Flip it in a one-line follow-up PR at least a day after this one applied on both routers. The lock matches source CIDRs, not `ZONE-TRUSTED`, because the legacy LAN shares that zone. DoH stays possible. ## IPv6 No change. There is no WAN v6 (ipv6.tf), so there is no public v6 DNS path to lock. The RAs carry no RDNSS: the routers have no v6 resolvers to advertise, and arch-ws on VLAN 30 shows no `IP6.DNS` today. ## Sim results, 2026-11-19 `routeros/sim` on the containerlab pair r1/r2 with the harness OpenBao. Fixtures beyond the committed sim root: - A VLAN 20 container at `10.30.20.53` runs dnsmasq on `10.30.100.53` in place of the recursor. `routeros/sim` routes `10.30.100.0/24` to it in place of c1's BGP route. - DHCP clients on VLAN 40 and VLAN 1 (veths on the lab bridge), and the lab client on VLAN 30. - The isp CHR answers DNS on `100.64.0.1` and plays the public resolver on the WAN. The lab has no internet, so `8.8.8.8` itself can't be tested. The lock rules match the port and the WAN interface list and ignore the destination address, so the isp listener exercises them the same way. | Case | Result | |---|---| | baseline (master) | 308 resources applied, second plan empty; every client gets `8.8.8.8 1.1.1.1` | | A: route only, today's firewall | iot -> recursor: **no answer** (finding 1 reproduced); trusted and legacy LAN answer | | 1: stand-in down | plan: 16 add, 10 change (DHCP 10/30/40/50 only, allows, move, probe, gate). Gate: `down` for 120 s, exit 1. **0 changes on the routers** besides the probe; all DHCP networks still public; gate tainted, next plan replaces it | | 2: stand-in up | gate `up` after 5 s, apply complete. Leases: VLAN 40 and 30 `10.30.100.53`, VLAN 1 `8.8.8.8 1.1.1.1`. iot -> recursor udp+tcp answers; WAN DNS still answers everywhere (no lock) | | 5: second plan | empty | | 3: lock on (`-var client_dns_lock=true`) | 8 rules per router, ordered after `fw-dnat`, before `fw-trusted`. iot and trusted -> WAN DNS udp+tcp: **no answer**; ICMP to the WAN still passes; legacy LAN -> WAN DNS answers; recursor answers everywhere. Second plan empty | | 4a: stand-in killed after the apply | both routers' `resolver-gate` probe goes `down`; the next plan is empty (no gate re-run, applies not blocked) | | 4b: rollback (`sim/rollback/run.sh g`, new) | the arm's baseline is `[anchor peer peer-web recursor]`; dnsmasq stopped inside the 180 s window; the judge loaded the backup 6 s after the fire time; the change's route is gone and the `rolled-back-` marker is written: PASS | The new lock rules took effect about 2-3 s after the apply returned. In a timestamped loop, one query in that window got an answer and every later one was dropped. A gap in that direction only lets DNS through. Two first-run misses in the sim log came from the fixture, not the change: dnsmasq didn't restart (log file permissions), so the gate correctly refused a second time; and one UDP query timed out right after a client's lease renewal. `task routeros:validate` (all three device roots), `routeros:guard`, `tofu fmt -check`, and shellcheck on both scripts all pass. ## Not proven - A plan of the real roots. The router roots are not in the branch planner (#97), and I did not run a local plan with production credentials. The sim root instantiates the same modules. - The production rollback window with a real RB5009 reboot (unchanged from #74). ## Rollout (human awake) 1. Merge. Watch `routeros-rb5009-a`, then `-b` on mini (approvePlan auto; never both at once). Each runner log should show `resolver-gate[...] probe resolver-gate: up`. 2. On a VLAN 30 or 40 device that is not arch-ws (arch-ws resolves via Tailscale): renew DHCP, check the resolver is `10.30.100.53`, then `dig resolver.caosh.int.animeteamspeak.moe`. 3. Rollback: revert this PR. The gate holds the switch while the recursor is down, and the judge covers a failure inside the window. 4. After at least one lease time on both routers: the follow-up PR with `client_dns_lock = true`, then check that `dig @8.8.8.8 example.com` times out from VLAN 30. Docs: ADR-0008 rule amended (dated), `docs/routeros/README.md` "Client DNS", `docs/routeros/rollback.md` scenario G.
DHCP on VLANs 10, 30, 40 and 50 hands out 10.30.100.53 (modules/site
client_dns). The legacy LAN (mini runs the tofu-controller, iac#50), VLAN 20
and the routers themselves keep the public resolvers.

modules/router dns.tf: a netwatch dns probe plus terraform_data.resolver_gate
(scripts/resolver-gate.sh polls /rest/tool/netwatch; the provider hides
status). DHCP networks and firewall rules depend on it, so a dead recursor
fails the apply before anything client-facing changes. mgmt/iot/guest get an
accept to the recursor on 53. The DNS lock (53/853 to the WAN by source CIDR)
is in the code behind client_dns_lock = false: leases are 1d, so it ships in
a later step. rb5009-*/rollback.tf gain a recursor probe; sim/rollback
scenario G proves the judge restores on a dead resolver.

Part of lab/clusters#1673.
ginjiruu merged commit 8c69089620 into master 2026-11-19 14:19:08 +00:00
Sign in to join this conversation.
No reviewers
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
lab/iac!163
No description provided.