homek8s/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft

52 lines
2.4 KiB
Text
Raw Normal View History

#!/usr/sbin/nft -f
# Gateway listener host firewall on siriussec: the listeners that must answer
# the WireGuard mesh and the pod network only, never the LAN.
#
# Ports and who they serve:
# 8080 public — Cloudflare tunnel origin (cloudflared runs on rpi)
# 8081 internal — Grafana
# 8084 internal — Hubble UI
# 8085 internal — Metabase
# 8086 internal — Customer 1 lab Odoo
# 8087 internal — Customer 1 lab Metabase
#
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so every
# listener is 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.
#
# 8080 is in this set on purpose. `gateway-system/public` serves the public
# hostnames and used to answer 192.168.1.0/24 over plain HTTP; a spoofed
# `Host:` header then served Forgejo and every public site without Cloudflare's
# TLS, WAF, rate limits or bot protection, and put credentials on the wire
# inside the LAN. The only legitimate client of :8080 is the tunnel origin —
# cloudflared on rpi (10.10.0.1), which connects to 10.10.0.2:8080 over the
# WireGuard mesh — so the saddr rule below covers it. Nothing may reach :8080
# from the LAN.
#
# Adding a listener: add its 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 { 8080, 8081, 8084, 8085, 8086, 8087 } iifname "lo" counter accept
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes;
# 10.10.0.1 = the cloudflared tunnel origin) and the pod network
# (in-cluster probes, gateway to service traffic)
tcp dport { 8080, 8081, 8084, 8085, 8086, 8087 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept
# everything else: LAN, tailscale, public
tcp dport { 8080, 8081, 8084, 8085, 8086, 8087 } counter drop
}
}