diff --git a/nixos/snowglobe.nix b/nixos/snowglobe.nix index aafb493b4212b2983d9b3bcf5c4e49a3c7bab32f..69c2bce73b8665bd70d2c56252073d3fda306d09 100644 --- a/nixos/snowglobe.nix +++ b/nixos/snowglobe.nix @@ -35,10 +35,10 @@ in ip6tables -A nixos-fw -i enp4s0 -s fe80::/10 -p tcp --dport 445 -j nixos-fw-accept ip6tables -A nixos-fw -i enp4s0 -s fc00::/7 -p tcp --dport 445 -j nixos-fw-accept '' + '' - iptables -t raw -N sandbox-egress 2>/dev/null || iptables -t raw -F sandbox-egress - iptables -t raw -A sandbox-egress -d ${(builtins.head config.networking.interfaces.enp4s0.ipv4.addresses).address} -p tcp --dport 15432 -j RETURN - ${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" ]} - iptables -t raw -C PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || iptables -t raw -I PREROUTING -i sandbox0 -j sandbox-egress + iptables -t mangle -N sandbox-egress 2>/dev/null || iptables -t mangle -F sandbox-egress + iptables -t mangle -A sandbox-egress -d ${(builtins.head config.networking.interfaces.enp4s0.ipv4.addresses).address} -p tcp --dport 15432 -j RETURN + ${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" ]} + 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 ''; # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN. @@ -56,9 +56,9 @@ in systemd.services.nomad.restartTriggers = [ config.environment.etc."cni/net.d/sandbox.conflist".source ]; networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ]; networking.firewall.extraStopCommands = '' - iptables -t raw -D PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || true - iptables -t raw -F sandbox-egress 2>/dev/null || true - iptables -t raw -X sandbox-egress 2>/dev/null || true + iptables -t mangle -D PREROUTING -i sandbox0 -m conntrack --ctstate NEW -j sandbox-egress 2>/dev/null || true + iptables -t mangle -F sandbox-egress 2>/dev/null || true + iptables -t mangle -X sandbox-egress 2>/dev/null || true ''; services.caddy.virtualHosts."${spacebarVoice.subdomain}.${config.environment.variables.SNOWGLOBE_DOMAIN}".extraConfig = ''