2026-10-27 00:35:09 -04:00
|
|
|
#!/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),
|
2026-11-22 00:32:31 -05:00
|
|
|
# 8084 = Hubble UI (`internal` Gateway listener hubble-ui),
|
2026-11-22 02:15:56 -05:00
|
|
|
# 8085 = Metabase (`metabase` Gateway listener http-internal),
|
2026-11-24 01:46:25 -05:00
|
|
|
# 8086 = Customer 1 lab Odoo (`customer1-odoo` Gateway),
|
|
|
|
|
# 8087 = Customer 1 lab Metabase (`customer1-metabase` Gateway).
|
2026-10-27 00:35:09 -04:00
|
|
|
# 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
|
|
|
|
|
|
2026-11-22 02:15:56 -05:00
|
|
|
PORTS="${PORTS:-8081 8084 8085 8086 8087}"
|
2026-10-27 00:35:09 -04:00
|
|
|
|
|
|
|
|
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
|
2026-11-22 00:32:31 -05:00
|
|
|
done
|