homek8s/infrastructure/networking/internal/dns/README.md

56 lines
2.3 KiB
Markdown
Raw Normal View History

# `lab.internal` resolver (WireGuard only)
Authoritative for the `lab.internal` zone and a forwarder for everything else,
running as **dnsmasq on rpi** (the WireGuard hub) at `10.10.0.1:53` and
`10.20.0.2:53`. It is a **host** service, not a cluster object — deliberately
not behind Cilium's internal Gateway, so it cannot inherit the Envoy
listener flapping (`t_e9564aa3`).
Full write-up, client instructions and rollback: `docs/internal-wireguard-services.md` §11.
## Files
| File | Installed to | Purpose |
|---|---|---|
| `lab-internal.conf` | `/etc/dnsmasq.d/lab-internal.conf` | zone authority (`local=/lab.internal/`), records file, bind list |
| `lab-internal.hosts` | `/etc/dnsmasq-lab-internal.hosts` | records, hosts(5) syntax — one line per name |
| `rpi-ufw-dns.sh` | — | ufw: allow 53 from mesh/hub-spokes/pods, deny everything else (inserted above the LAN catch-all) |
| `install-rpi-dns.sh` | — | installs everything, restarts dnsmasq, prints the bind view |
`lab-internal.hosts` is installed **outside** `/etc/dnsmasq.d` because the
systemd unit parses every file in that directory as config (`-7
/etc/dnsmasq.d`); a hosts file there aborts the start with `bad option`.
## Install / update (root on rpi)
```bash
bash install-rpi-dns.sh
```
## Add a record
```bash
# 1. edit lab-internal.hosts in git and commit, then on rpi:
sudo install -m 0644 lab-internal.hosts /etc/dnsmasq-lab-internal.hosts
sudo systemctl reload dnsmasq # re-reads addn-hosts, no restart
dig +short grafana.lab.internal @10.10.0.1
```
## Verify
```bash
sudo ss -lntuH 'sport = :53' # 127.0.0.1, 10.10.0.1, 10.20.0.2, [::1] only
sudo iptables -L ufw-user-input -n -v | grep dpt:53
# from a WireGuard client (not on the LAN):
dig +short grafana.lab.internal @10.10.0.1 # 10.10.0.2
dig +short example.com @10.10.0.1 # forwards, public answer
# negative, from the LAN: must time out (DROP)
dig +time=3 grafana.lab.internal @192.168.1.125
```
## Why the client must use `10.10.0.1` as its DNS
Android/iOS apply the tunnel's DNS as the resolver for the **whole device**
while the tunnel is up — there is no per-domain split. This resolver therefore
answers `lab.internal` locally and forwards everything else upstream, so public
DNS keeps working. Clearing the field in the WireGuard app is the rollback.