Skip to content

Commit 7f34f0b

Browse files
committed
fix: allow IPv6 output to fdaa::/16 for Fly SSH, use atomic ip6tables-restore
1 parent 7153e62 commit 7f34f0b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

network/refresh-iptables.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ echo "COMMIT" >> "$RULES_FILE"
3434

3535
iptables-restore < "$RULES_FILE"
3636

37-
ip6tables -P OUTPUT DROP 2>/dev/null || true
38-
ip6tables -F OUTPUT 2>/dev/null || true
39-
ip6tables -A OUTPUT -o lo -j ACCEPT 2>/dev/null || true
40-
# Allow established connections (needed for SSH responses over Fly's fdaa:: network)
41-
ip6tables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 2>/dev/null || true
37+
# IPv6 rules: use ip6tables-restore for atomic application (no window where
38+
# policy is DROP but rules are flushed, which would kill active SSH sessions)
39+
ip6tables-restore 2>/dev/null <<'IP6RULES' || true
40+
*filter
41+
:INPUT ACCEPT [0:0]
42+
:FORWARD ACCEPT [0:0]
43+
:OUTPUT DROP [0:0]
44+
-A OUTPUT -o lo -j ACCEPT
45+
-A OUTPUT -d fdaa::/16 -j ACCEPT
46+
-A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
47+
COMMIT
48+
IP6RULES
4249

4350
rm -f "$RULES_FILE"
4451
echo "[NETWORK] iptables refreshed at $(date)" >&2

0 commit comments

Comments
 (0)