homek8s/infrastructure/networking/internal/host-firewall/rpi-ufw-internal-gw.sh
Lance Walters a287dc8dfa hubble: move the UI listener to 8084 — 8082 is taken on rpi
Cilium binds every Gateway listener on 0.0.0.0 on EVERY gateway node, and the Pi
still runs leftover Docker site containers: handyman-site holds 127.0.0.1:8082
and its nginx holds 127.0.0.1:8083 (a 127.0.0.1 bind still blocks a 0.0.0.0
one). Binding 8082 there made xDS reject the listener on rpi
("cannot bind '0.0.0.0:8082': Address already in use" at ~2/s) and restarted
cilium-envoy on the node that fronts the public ingress — the UI worked or not
depending on which node answered.

8084 measured free on both gateway nodes (rpi, siriussec) before the change.
Firewall moved with it: siriussec nft dport set { 8081, 8084 }, rpi ufw trio for
8084 inserted above the LAN catch-all and the 8082 rules deleted.

URL: http://10.10.0.2:8084/ (bare IP, no /etc/hosts) — same as Grafana on 8081.
2026-10-27 00:44:36 -04:00

31 lines
1.2 KiB
Shell

#!/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),
# 8084 = 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 8084}"
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