authoravatarclover caruso<git@paperclover.net>2026-11-22 13:52:25-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 20:28:52-08:00
log6f74560e1efd492076d18c4f79ca691a64be6aa4
tree79a82b2bbfdafd69c07c7661161b1748d8462ddd
parent3f739d1e5976489850e09050207c69e0137ce7c3
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Drop only new sandbox connections to private addresses

Replies to published ports travel to the host bridge address, so the filter must match connection state and run after conntrack. Assisted-by: claude-sonnet-5.5

1 files changed, 7 insertions(+), 7 deletions(-)

nixos/snowglobe.nix+7-7
...@@ -35,10 +35,10 @@ in...@@ -35,10 +35,10 @@ in
35 ip6tables -A nixos-fw -i enp4s0 -s fe80::/10 -p tcp --dport 445 -j nixos-fw-accept35 ip6tables -A nixos-fw -i enp4s0 -s fe80::/10 -p tcp --dport 445 -j nixos-fw-accept
36 ip6tables -A nixos-fw -i enp4s0 -s fc00::/7 -p tcp --dport 445 -j nixos-fw-accept36 ip6tables -A nixos-fw -i enp4s0 -s fc00::/7 -p tcp --dport 445 -j nixos-fw-accept
37 '' + ''37 '' + ''
38 iptables -t raw -N sandbox-egress 2>/dev/null || iptables -t raw -F sandbox-egress38 iptables -t mangle -N sandbox-egress 2>/dev/null || iptables -t mangle -F sandbox-egress
39 iptables -t raw -A sandbox-egress -d ${(builtins.head config.networking.interfaces.enp4s0.ipv4.addresses).address} -p tcp --dport 15432 -j RETURN39 iptables -t mangle -A sandbox-egress -d ${(builtins.head config.networking.interfaces.enp4s0.ipv4.addresses).address} -p tcp --dport 15432 -j RETURN
40 ${lib.concatMapStringsSep "\n" (range: "iptables -t raw -A sandbox-egress -d ${range} -j DROP") [ "10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16" "100.64.0.0/10" "169.254.0.0/16" ]}40 ${lib.concatMapStringsSep "\n" (range: "iptables -t mangle -A sandbox-egress -d ${range} -j DROP") [ "10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16" "100.64.0.0/10" "169.254.0.0/16" ]}
41 iptables -t raw -C PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || iptables -t raw -I PREROUTING -i sandbox0 -j sandbox-egress41 iptables -t mangle -C PREROUTING -i sandbox0 -m conntrack --ctstate NEW -j sandbox-egress 2>/dev/null || iptables -t mangle -I PREROUTING -i sandbox0 -m conntrack --ctstate NEW -j sandbox-egress
42 '';42 '';
4343
44 # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN.44 # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN.
...@@ -56,9 +56,9 @@ in...@@ -56,9 +56,9 @@ in
56 systemd.services.nomad.restartTriggers = [ config.environment.etc."cni/net.d/sandbox.conflist".source ];56 systemd.services.nomad.restartTriggers = [ config.environment.etc."cni/net.d/sandbox.conflist".source ];
57 networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ];57 networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ];
58 networking.firewall.extraStopCommands = ''58 networking.firewall.extraStopCommands = ''
59 iptables -t raw -D PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || true59 iptables -t mangle -D PREROUTING -i sandbox0 -m conntrack --ctstate NEW -j sandbox-egress 2>/dev/null || true
60 iptables -t raw -F sandbox-egress 2>/dev/null || true60 iptables -t mangle -F sandbox-egress 2>/dev/null || true
61 iptables -t raw -X sandbox-egress 2>/dev/null || true61 iptables -t mangle -X sandbox-egress 2>/dev/null || true
62 '';62 '';
6363
64 services.caddy.virtualHosts."${spacebarVoice.subdomain}.${config.environment.variables.SNOWGLOBE_DOMAIN}".extraConfig = ''64 services.caddy.virtualHosts."${spacebarVoice.subdomain}.${config.environment.variables.SNOWGLOBE_DOMAIN}".extraConfig = ''