hubble: bare-IP listener (8082) for the UI + WireGuard-only firewall on both gateway nodes

Operator addendum: internal services must be reachable by bare IP+port, because
a phone cannot edit /etc/hosts. A hostname-scoped route does not match
`Host: 10.10.0.2:8081` (Envoy 404), and a hostname-less `PathPrefix /` cannot
share a listener with it — so hubble-ui gets its own listener (`hubble-ui`, port
8082) with a route that sets no hostnames. http://10.10.0.2:8082/ and
http://hubble.lab.internal:8082/ both hit the UI.

Firewall: siriussec nft table now matches `dport { 8081, 8082 }` and starts with
`destroy table` so re-running the unit replaces (not appends) the rules; the rpi
ufw script is generalised to a PORTS list and inserts each port above the LAN
catch-all. Both hosts applied and verified before the listener was programmed.

docs: internal gateway section, host-firewall README.
This commit is contained in:
Lance Walters 2026-10-27 00:35:09 -04:00
commit 7ca85669b2
8 changed files with 83 additions and 43 deletions

View file

@ -282,7 +282,9 @@ A single `ReferenceGrant` exists (`gateway-system/forgejo`) for the cross-namesp
### 4.6 Second gateway: `internal`
`internal/internal` (namespace `internal`) is a Cilium Gateway on **port 8081** with no HTTPRoute attached and no tunnel mapping *(live)*. It is a spare private listener, currently unused.
`internal/internal` (namespace `internal`) is a Cilium Gateway on **port 8081**, `allowedRoutes: All`, with no tunnel mapping. It carries the WireGuard-only services — currently **Grafana** (`http://grafana.lab.internal:8081/`) and **Hubble UI** (`http://hubble.lab.internal:8081/`). The enforcement point is the *host* firewall on both gateway nodes (nft `table inet internal_gw` on siriussec, ufw rules above the LAN catch-all on rpi), not the Gateway: a listener port is reachable on every node address the moment it is Programmed. Full pattern, negative tests and the add-next-service recipe: `docs/internal-wireguard-services.md`.
Neither hostname is in the cloudflared ingress list, and `*.lab.internal` resolves nowhere public — `Host: <name>.lab.internal` on the public gateway (`10.10.0.2:8080`) answers **404**.
---

View file

@ -8,11 +8,14 @@ metadata:
app.kubernetes.io/part-of: cilium
spec:
parentRefs:
# Dedicated listener on port 8082 — deliberately NOT the shared 8081
# listener. There is no `hostnames` field here on purpose: the route must
# match a request whose Host header is the bare IP (10.10.0.2:8082), which
# is the only form a phone can use. A hostname-less route has to own its
# listener, hence the separate port.
- name: internal
namespace: internal
sectionName: http-internal
hostnames:
- hubble.lab.internal
sectionName: hubble-ui
rules:
- matches:
- path:

View file

@ -18,3 +18,17 @@ spec:
allowedRoutes:
namespaces:
from: All
# One listener per service that must be reachable by BARE IP.
#
# A hostname-scoped route (`hostnames: [x.lab.internal]`) does not match a
# request whose Host is the IP, so `curl http://10.10.0.2:8081/` returns 404
# and a phone (no /etc/hosts) cannot use the service at all. The fix is a
# listener whose route has no `hostnames` — but a hostname-less PathPrefix /
# route swallows every request on its listener, so it cannot share a port
# with a hostname-routed one. Hence: new service => new port.
- name: hubble-ui
protocol: HTTP
port: 8082
allowedRoutes:
namespaces:
from: All

View file

@ -10,10 +10,12 @@ are *both* listening on the LAN interfaces; the Gateway API object cannot say
| Host | Mechanism | Artifact |
|------|-----------|----------|
| siriussec (10.10.0.2) | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
| rpi (10.10.0.1) | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-8081.sh` |
| rpi (10.10.0.1) | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
Effective policy for `:8081` on both hosts: **accept from 10.10.0.0/24 and
10.244.0.0/16, accept on lo, drop everything else** (LAN, tailscale, public).
Effective policy for `:8081` (Grafana) and `:8082` (Hubble UI) on both hosts:
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
new internal listener port is a LAN exposure until it is added here.
These are host units, not Flux objects — a node reinstall has to re-apply them.
Install:
@ -25,7 +27,7 @@ install -m 0644 internal-gw-firewall.service /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now internal-gw-firewall.service
# rpi, as root
bash rpi-ufw-8081.sh
bash rpi-ufw-internal-gw.sh
```
Verify:
@ -34,7 +36,7 @@ Verify:
# siriussec
nft list table inet internal_gw
# rpi
ufw status | grep 8081
ufw status | grep -E '8081|8082'
```
Negative test from the LAN must be a timeout (DROP), never 200:
@ -44,6 +46,8 @@ curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.179:8081/ # em
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.125:8081/ # empty/000
```
When a new internal listener port is added, add the same three lines with the
new port to both artifacts — one deny for the port, allows for the mesh and the
pod CIDR, inserted above the LAN catch-all.
When a new internal listener port is added, add it to the `tcp dport { … }` set
in `siriussec-internal-gw.nft` and to `PORTS` in `rpi-ufw-internal-gw.sh` (which
inserts one deny for the port plus mesh and pod-CIDR allows above the LAN
catch-all), then reinstall both and re-run the two negative tests above with the
new port.

View file

@ -4,7 +4,7 @@
# Flux-managed); the file lives in git at
# infrastructure/networking/internal/host-firewall/.
[Unit]
Description=Restrict the internal Gateway listener (8081) to WireGuard
Description=Restrict the internal Gateway listeners (8081, 8082) to WireGuard
After=network-online.target
Wants=network-online.target

View file

@ -1,22 +0,0 @@
#!/bin/bash
# rpi: restrict the internal Gateway listener (TCP 8081) to WireGuard + pods.
#
# ufw on rpi already has `allow from 192.168.1.0/24` (any port), so the deny has
# to sit ABOVE it — hence `ufw insert`, not `ufw allow/deny` (which appends).
# Final order for 8081: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
#
# Idempotent: re-running after the rules exist is a no-op.
# Run as root on rpi (192.168.1.125).
set -euo pipefail
if ufw status | grep -q '8081'; then
echo "8081 rules already present:"
ufw status | grep '8081'
exit 0
fi
ufw insert 1 deny to any port 8081 proto tcp comment 'internal gateway: wg only'
ufw insert 1 allow from 10.10.0.0/24 to any port 8081 proto tcp comment 'internal gateway (wg mesh)'
ufw insert 2 allow from 10.244.0.0/16 to any port 8081 proto tcp comment 'internal gateway (pods)'
ufw status | grep '8081'

View file

@ -0,0 +1,31 @@
#!/bin/bash
# rpi: restrict the internal Gateway listeners to WireGuard + pods.
#
# ufw on rpi already has `allow from 192.168.1.0/24` (any port), so the deny has
# to sit ABOVE it — hence `ufw insert`, not `ufw allow/deny` (which appends).
# Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
#
# Ports: 8081 = Grafana (`internal` Gateway listener http-internal),
# 8082 = Hubble UI (`internal` Gateway listener hubble-ui).
# Add a new internal listener port to PORTS; the loop is idempotent, so
# re-running after a port is already firewalled only adds what is missing.
#
# Run as root on rpi (192.168.1.125).
set -euo pipefail
PORTS="${PORTS:-8081 8082}"
for port in $PORTS; do
if ufw status | grep -q "${port}/tcp"; then
echo "$port rules already present:"
ufw status | grep "${port}/tcp"
continue
fi
ufw insert 1 deny to any port "$port" proto tcp comment 'internal gateway: wg only'
ufw insert 1 allow from 10.10.0.0/24 to any port "$port" proto tcp comment 'internal gateway (wg mesh)'
ufw insert 2 allow from 10.244.0.0/16 to any port "$port" proto tcp comment 'internal gateway (pods)'
echo "$port rules installed:"
ufw status | grep "${port}/tcp" || true
done

View file

@ -1,26 +1,34 @@
#!/usr/sbin/nft -f
# Internal (WireGuard-only) gateway listener: TCP 8081.
# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana) and 8082
# (Hubble UI).
#
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the
# internal listener is open on the LAN interface the moment the Gateway is
# programmed. This table makes :8081 answer only from the WireGuard mesh and the
# internal listeners are open on the LAN interface the moment the Gateway is
# programmed. This table makes them answer only from the WireGuard mesh and the
# pod network. DROP (not reject) so a LAN scan sees a timeout, not a port that
# tells you something is listening.
#
# Loaded by internal-gw-firewall.service on siriussec.
# The equivalent on rpi is the ufw rules in rpi-ufw-8081.sh.
# Adding an internal service: add its listener port to the set in all three
# rules below, reinstall this file, then
# `systemctl reload-or-restart internal-gw-firewall.service`. The same list
# must also be added to the rpi ufw rules (rpi-ufw-internal-gw.sh).
#
# Loaded by internal-gw-firewall.service on siriussec. `destroy` (not `delete`)
# so re-running the unit REPLACES the table instead of appending a second copy
# of the rules, and does not fail when the table does not exist yet.
destroy table inet internal_gw
table inet internal_gw {
chain input {
type filter hook input priority filter; policy accept;
# local process / kubelet probes
tcp dport 8081 iifname "lo" accept
tcp dport { 8081, 8082 } iifname "lo" accept
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes)
# and the pod network (in-cluster scrapers, probes)
tcp dport 8081 ip saddr { 10.10.0.0/24, 10.244.0.0/16 } accept
tcp dport { 8081, 8082 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } accept
# everything else: LAN, tailscale, public
tcp dport 8081 counter drop
tcp dport { 8081, 8082 } counter drop
}
}