internal DNS: lab.internal resolver on the WG hub (dnsmasq on rpi)
WireGuard clients apply the tunnel DNS to the whole device, so the hub resolver answers lab.internal authoritatively and forwards everything else: - dnsmasq on rpi, bound to lo/wg0/wg-remote only, 10.10.0.1 + 10.20.0.2 - grafana.lab.internal, hubble.lab.internal -> 10.10.0.2 (hosts file, one line per record) - ufw: 53 allowed from 10.10.0.0/24, 10.20.0.0/24, 10.244.0.0/16; dropped everywhere else, inserted above the LAN catch-all - docs: zone, per-client instructions (phone is a linode-hub spoke), rollback
This commit is contained in:
parent
48b2b6ac01
commit
ead60fface
6 changed files with 365 additions and 0 deletions
|
|
@ -436,3 +436,211 @@ node that does not run the backend completes the TCP handshake and never ACKs
|
|||
(the same co-location fault as the public gateway). The Gateway status lists
|
||||
both node addresses because the class schedules on every `gateway=true` node;
|
||||
the working address is the one the backends are pinned to, `10.10.0.2`.
|
||||
|
||||
## 11. Internal DNS: the `lab.internal` zone
|
||||
|
||||
Facts: zone `lab.internal`, resolver `10.10.0.1` (and `10.20.0.2`), records
|
||||
`grafana.lab.internal` and `hubble.lab.internal` → `10.10.0.2`, configured by
|
||||
`infrastructure/networking/internal/dns/`. The record does **not** carry a
|
||||
port: Grafana stays on `:8081`, Hubble UI on `:8084`, so the URLs are
|
||||
`http://grafana.lab.internal:8081/` and `http://hubble.lab.internal:8084/`.
|
||||
|
||||
### 11.1 What "split DNS" can and cannot mean here
|
||||
|
||||
The WireGuard clients in use (Android, iOS, and the desktop clients) hand the
|
||||
tunnel's DNS server to the OS as **the device resolver for everything while
|
||||
the tunnel is up**. There is no client-side per-domain split, and nothing on
|
||||
the server side can create one. So:
|
||||
|
||||
- the resolver on the hub **answers `lab.internal` itself** (authoritative,
|
||||
`local=/lab.internal/`, never forwarded), and
|
||||
- **forwards every other query** to the upstreams in the Pi's
|
||||
`/etc/resolv.conf` (today `100.100.100.100` = Tailscale MagicDNS, which
|
||||
forwards to the ISP resolvers `137.118.204.9` / `137.118.1.32`).
|
||||
|
||||
Public resolution therefore keeps working *through* the tunnel resolver — it
|
||||
is not "split on the client", it is "one resolver that knows one private zone
|
||||
and forwards the rest". Public names stay on public DNS; there are no
|
||||
split-horizon records for `siriusdevops.com`, `piedmonthomesvc.com` or
|
||||
`siriusgrowthsolutions.com` and there must not be.
|
||||
|
||||
**The risk this creates:** while the tunnel is up, a dead resolver is a dead
|
||||
internet connection for that device. Rollback is in §11.6.
|
||||
|
||||
### 11.2 Where it runs, and why not in the cluster
|
||||
|
||||
`dnsmasq` **on rpi** — the WireGuard hub, `10.10.0.1` on `wg0` and `10.20.0.2`
|
||||
on `wg-remote`. It is a host service, deliberately **not** behind Cilium's
|
||||
internal Gateway: those listeners have their own failure mode (`t_e9564aa3`,
|
||||
Envoy on the wrong node answers 503 after 5 s) and DNS must not inherit it.
|
||||
Host ports on the Pi over WireGuard work (SSH on `10.10.0.1:22` is proof).
|
||||
|
||||
dnsmasq was already the Pi's resolver (it also answers `.rpi.local`), so this
|
||||
extends it instead of adding a second resolver on port 53. Artifacts:
|
||||
|
||||
| File | Installed to | Purpose |
|
||||
|---|---|---|
|
||||
| `dns/lab-internal.conf` | `/etc/dnsmasq.d/lab-internal.conf` | zone authority, `addn-hosts`, bind list |
|
||||
| `dns/lab-internal.hosts` | `/etc/dnsmasq-lab-internal.hosts` | the records (hosts(5) syntax) |
|
||||
| `dns/rpi-ufw-dns.sh` | — | ufw allow/deny for `:53` |
|
||||
| `dns/install-rpi-dns.sh` | — | installs all of the above, restarts, prints bind view |
|
||||
|
||||
The hosts file lives **outside** `/etc/dnsmasq.d` on purpose: the unit passes
|
||||
`-7 /etc/dnsmasq.d`, so every file in that directory is parsed as config, and a
|
||||
hosts file there fails the start with `bad option at line 9`.
|
||||
|
||||
Install / re-install (host artifacts — a Pi reinstall has to re-run this):
|
||||
|
||||
```bash
|
||||
bash infrastructure/networking/internal/dns/install-rpi-dns.sh # as root on rpi
|
||||
```
|
||||
|
||||
### 11.3 Listen addresses and the firewall boundary
|
||||
|
||||
`bind-dynamic` + `interface=lo`, `interface=wg0`, `interface=wg-remote`:
|
||||
53 is bound on `127.0.0.1`, `10.10.0.1`, `10.20.0.2` (and `::1`) and **nowhere
|
||||
else** — not on `192.168.1.125`, not on the tailscale address. `bind-dynamic`
|
||||
also means a WireGuard interface that is down at boot is picked up when it
|
||||
appears, with no restart and no hard `Requires=` on a `wg-quick@` template unit.
|
||||
|
||||
ufw is the second layer (and the one that produces the DROP evidence), inserted
|
||||
above the `allow from 192.168.1.0/24` catch-all:
|
||||
|
||||
```
|
||||
53/udp,tcp ALLOW IN 10.10.0.0/24 # mesh (siriussec, Pi-hub peers)
|
||||
53/udp,tcp ALLOW IN 10.20.0.0/24 # remote hub + its spokes (the phone, Legion)
|
||||
53/udp,tcp ALLOW IN 10.244.0.0/16 # pods
|
||||
53/udp,tcp DENY IN Anywhere # LAN, tailscale, internet
|
||||
```
|
||||
|
||||
`10.20.0.0/24` is not optional: the phone and Legion are spokes of the
|
||||
**linode** hub (`10.20.0.1`), so their DNS packets reach the Pi on `wg-remote`
|
||||
with source `10.20.0.3` / `10.20.0.5`. With only the mesh subnet allowed, the
|
||||
hub-spoke clients time out (§11.7 negative 3).
|
||||
|
||||
No Cloudflare change: the tunnel's ingress list is an allow-list of HTTP
|
||||
hostnames pointing at `:8080`; UDP/TCP 53 is not proxied by it and there is no
|
||||
port-forward on the LAN edge. `*.lab.internal` has no public record.
|
||||
|
||||
### 11.4 Adding a record
|
||||
|
||||
1. Add one line to `dns/lab-internal.hosts` — `<address>\t<name>` — commit it.
|
||||
2. On rpi: `sudo install -m 0644 dns/lab-internal.hosts /etc/dnsmasq-lab-internal.hosts
|
||||
&& sudo systemctl reload dnsmasq` (a reload re-reads `addn-hosts`; no restart,
|
||||
no dropped queries).
|
||||
3. Verify: `dig +short <name> @10.10.0.1`.
|
||||
|
||||
Only `lab.internal` is authoritative. A query for anything else, *including*
|
||||
`siriusdevops.com`, is forwarded — do not add public names here.
|
||||
|
||||
Which address to record: **`10.10.0.2`** today, because siriussec is the only
|
||||
node carrying `node-role.kubernetes.io/gateway=true` and therefore the only one
|
||||
with a listener that can complete a request to the backends. If that changes
|
||||
(the label moving back to rpi once the arm64/Envoy co-location issue is solved),
|
||||
it is a one-line change in `dns/lab-internal.hosts` + reload.
|
||||
|
||||
### 11.5 Client configuration
|
||||
|
||||
The phone is **`Pixel 9 Pro`**, WireGuard peer `10.20.0.3` on the **linode**
|
||||
hub (`10.20.0.1:51820`) — not a `wg0` peer of the Pi: its handshake is
|
||||
seconds old on the linode hub, while the Pi's `wg0` peer `10.10.0.4`
|
||||
(`Peer SiriusMobile`) has been stale for days. Its DNS therefore has to be set
|
||||
in the phone's own WireGuard profile. The Pi's `wg0.conf` peers (and the
|
||||
`wgportal` DB) are *not* where the phone's DNS lives, and wgportal is not even
|
||||
running on the Pi today (`docker ps` has no wgportal container) — so nothing on
|
||||
the server side can push this; do not go looking for a portal toggle.
|
||||
|
||||
**Android (WireGuard app) — 3 steps:**
|
||||
|
||||
1. Open the WireGuard app → tap the tunnel → pencil (Edit) → **Interface**
|
||||
section → **DNS servers** → enter `10.10.0.1` (leave "Excluded applications"
|
||||
alone).
|
||||
2. Save, then toggle the tunnel **off and on** (Android keeps the old
|
||||
`resolver1` until the tunnel restarts).
|
||||
3. Check: browser to `http://grafana.lab.internal:8081/` → login page; and any
|
||||
public site still loads (proof forwarding works).
|
||||
|
||||
If that profile's `AllowedIPs` does not cover `10.10.0.0/24`, use **`10.20.0.2`**
|
||||
(the Pi's address on the hub subnet) instead — both answer, both are the same
|
||||
resolver.
|
||||
|
||||
**iOS:** WireGuard app → tunnel → Edit → *DNS Servers* → `10.10.0.1` → Save →
|
||||
toggle off/on.
|
||||
|
||||
**Desktop (wg-quick):** in the tunnel's `[Interface]` add `DNS = 10.10.0.1`
|
||||
and, because this is a non-systemd-resolved-specific option,
|
||||
`resolvconf`/`openresolv` must be present (`wg-quick` uses it to point the
|
||||
system resolver at the tunnel); then `wg-quick down <if> && wg-quick up <if>`.
|
||||
There is no per-domain split — the whole machine uses it while the tunnel is
|
||||
up.
|
||||
|
||||
Do not point a **cluster node** at this resolver: nodes and pods must keep
|
||||
their own DNS (`CoreDNS` / `/etc/resolv.conf`) or kubelet and pod lookups will
|
||||
break. This is for client devices only.
|
||||
|
||||
### 11.6 Rollback (do this first when DNS "breaks the internet")
|
||||
|
||||
On the device: WireGuard app → tunnel → Edit → clear the **DNS servers** field
|
||||
→ Save → toggle the tunnel off/on. That restores the OS resolver immediately.
|
||||
On the server: `sudo systemctl disable --now dnsmasq` stops the Pi's resolver
|
||||
(don't — it also serves `.rpi.local`); to remove only the zone, delete
|
||||
`/etc/dnsmasq.d/lab-internal.conf` and `/etc/dnsmasq-lab-internal.hosts` and
|
||||
`systemctl restart dnsmasq`. To close the port again, remove the six `wg-dns`
|
||||
ufw rules (`ufw status numbered`, then `ufw delete <n>`).
|
||||
|
||||
### 11.7 Verification log — 2026-10-27
|
||||
|
||||
Resolver: `dnsmasq` 2.91 on rpi, enabled at boot (`systemctl is-enabled dnsmasq`
|
||||
= `enabled`), ufw `enabled`. Listeners (no `0.0.0.0`, no LAN address):
|
||||
|
||||
```
|
||||
$ sudo ss -lntuH 'sport = :53'
|
||||
udp 127.0.0.1:53 udp 10.10.0.1:53 udp 10.20.0.2:53 udp [::1]:53
|
||||
tcp 127.0.0.1:53 tcp 10.10.0.1:53 tcp 10.20.0.2:53 tcp [::1]:53
|
||||
$ sudo journalctl -u dnsmasq -n 4
|
||||
using nameserver 100.100.100.100#53 # forwarded upstreams (tailscale MagicDNS)
|
||||
using only locally-known addresses for lab.internal
|
||||
read /etc/dnsmasq-lab-internal.hosts - 2 names
|
||||
```
|
||||
|
||||
`10.10.0.1:8081`/`:8084` flap. `:53` does not: it is a host socket, not Envoy.
|
||||
|
||||
**Positive — from a WireGuard client (Legion, `10.20.0.5`, via the linode hub):**
|
||||
|
||||
```
|
||||
$ dig +short grafana.lab.internal @10.10.0.1 -> 10.10.0.2
|
||||
$ dig +short hubble.lab.internal @10.10.0.1 -> 10.10.0.2
|
||||
$ dig +short grafana.lab.internal @10.20.0.2 -> 10.10.0.2
|
||||
$ dig +tcp +short grafana.lab.internal @10.10.0.1 -> 10.10.0.2
|
||||
$ dig +short example.com @10.10.0.1 -> 104.20.23.154 / 172.66.147.243 # forwarding
|
||||
$ dig nosuch.lab.internal @10.10.0.1 -> status: NXDOMAIN # authoritative, not forwarded
|
||||
```
|
||||
|
||||
From a mesh peer (`siriussec`, `10.10.0.2`): all three names `rcode 0`
|
||||
(`grafana.lab.internal`, `hubble.lab.internal`, `example.com`). From the Pi's
|
||||
own loopback: same, plus `nope.lab.internal` → `NXDOMAIN`.
|
||||
|
||||
**Negative — LAN and counters** (from Legion on `192.168.1.126`, same host that
|
||||
resolved fine over the tunnel a second earlier):
|
||||
|
||||
```
|
||||
$ dig +time=3 grafana.lab.internal @192.168.1.125 -> timed out, no servers could be reached
|
||||
$ dig +tcp +time=3 grafana.lab.internal @192.168.1.125 -> timed out
|
||||
$ sudo iptables -L ufw-user-input -n -v | grep dpt:53
|
||||
2 120 ACCEPT tcp 10.20.0.0/24 dpt:53 # hub spokes (the phone's path)
|
||||
3 188 ACCEPT udp 10.10.0.0/24 dpt:53 # mesh
|
||||
7 602 ACCEPT udp 10.20.0.0/24 dpt:53
|
||||
3 180 DROP tcp 0.0.0.0/0 dpt:53 # LAN / internet
|
||||
1 89 DROP udp 0.0.0.0/0 dpt:53
|
||||
```
|
||||
|
||||
**Regression:** `http://10.10.0.2:8081/` → 302 (Grafana login), `:8084/` → 200
|
||||
(Hubble UI), public sites through the tunnel unchanged (no Cloudflare object
|
||||
touched).
|
||||
|
||||
**Reboot survival:** `systemctl is-enabled dnsmasq` = `enabled`; the unit
|
||||
`Requires=network-online.target` and has **no** `Requires=`/`After=` on any
|
||||
`wg-quick@` template (which is `enabled` but currently `inactive` because `wg0`
|
||||
was brought up by hand — a hard dependency would fail the boot). `bind-dynamic`
|
||||
picks up `wg0`/`wg-remote` whenever they appear. Records and the bind list live
|
||||
in `/etc/dnsmasq*`, not in `/run`; ufw rules are persistent.
|
||||
|
|
|
|||
Loading…
Reference in a new issue