From d74cc1a8d62200247e10f3f419401b7bfa4a5b1c Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Mon, 30 Nov 2026 11:37:05 +0000 Subject: [PATCH] feat(podguard): PODGUARD_ALLOW4 ip.port pairs pods may reach inside BLOCK4 c0mpute.com (and infernetprotocol.com) live on dev2, which BLOCK4 drops for pods, so the new "Use c0mpute network" hub entry (#183) could not connect from a pod. ALLOW4 lets an operator open exactly one public port on a blocked box (bbs: 23.95.228.174 . 443). dev2 has no allowlist trusting the bbs IP on 443 (its Caddy only allows 127.0.0.1); SSH and every other port stay dropped. Co-Authored-By: Claude Opus 5.5 --- deploy/podguard.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deploy/podguard.sh b/deploy/podguard.sh index a9751ae..52a8f0b 100755 --- a/deploy/podguard.sh +++ b/deploy/podguard.sh @@ -17,6 +17,13 @@ # PODGUARD_BLOCK4="1.2.3.4, 5.6.7.8" # other servers pods must never reach # PODGUARD_BLOCK6="2001:db8::1" # PODGUARD_PUBPORTS="22, 70, 80, 119, 443, 563, 2222, 6697" # host ports pods MAY use +# PODGUARD_ALLOW4="23.95.228.174 . 443" # ip . tcp-port pairs pods MAY reach +# # even inside BLOCK4 (checked first) +# +# ALLOW4 exists for public HTTPS that happens to live on a blocked box: the +# c0mpute.com API (hub entry "Use c0mpute network") runs on dev2. Only list a +# port that serves the public internet anyway, on a box that trusts nothing by +# this host's IP on that port; SSH and every other port stay dropped. set -eu [ -f /etc/agentbbs/podguard.env ] && . /etc/agentbbs/podguard.env SVC_USER="${SVC_USER:-agentbbs}" @@ -33,6 +40,11 @@ PUBPORTS="${PODGUARD_PUBPORTS:-22, 70, 80, 119, 443, 563, 2222, 6697}" B4=""; B6="" [ -n "${PODGUARD_BLOCK4:-}" ] && B4="set block4 { type ipv4_addr; flags interval; elements = { $PODGUARD_BLOCK4 } }" [ -n "${PODGUARD_BLOCK6:-}" ] && B6="set block6 { type ipv6_addr; flags interval; elements = { $PODGUARD_BLOCK6 } }" +A4=""; RA4="" +if [ -n "${PODGUARD_ALLOW4:-}" ]; then + A4="set allow4 { type ipv4_addr . inet_service; elements = { $PODGUARD_ALLOW4 } }" + RA4="ip daddr . tcp dport @allow4 accept" +fi R4=""; R6="" [ -n "$B4" ] && R4="ip daddr @block4 counter drop" [ -n "$B6" ] && R6="ip6 daddr @block6 counter drop" @@ -41,6 +53,7 @@ nft -f - <