summary refs log tree commit diff
path: root/nixos/modules/services/networking/firewall.nix
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-09-15 20:42:40 -0700
committerWilliam A. Kennington III <william@wkennington.com>2014-09-15 20:42:40 -0700
commit43c2bc0f8c0f50eca0b0e47820ee503c14b4b152 (patch)
treec3be39d1764a1d18fe8840b5bfbba89340aa965e /nixos/modules/services/networking/firewall.nix
parent87eb8fcf834b8b7fb0dd6871e2e912c98052ee7d (diff)
parentfd7b9b42912c4b2be3320f22f6e6e7d2a83e01b6 (diff)
downloadnixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar.gz
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar.bz2
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar.lz
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar.xz
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.tar.zst
nixpkgs-43c2bc0f8c0f50eca0b0e47820ee503c14b4b152.zip
Merge pull request #4108 from wkennington/master.firewall
Firewall: Don't allow traffic during nixos-switch / reload
Diffstat (limited to 'nixos/modules/services/networking/firewall.nix')
-rw-r--r--nixos/modules/services/networking/firewall.nix18
1 files changed, 14 insertions, 4 deletions
diff --git a/nixos/modules/services/networking/firewall.nix b/nixos/modules/services/networking/firewall.nix
index 42914bfe5d6..b97ec8b4d43 100644
--- a/nixos/modules/services/networking/firewall.nix
+++ b/nixos/modules/services/networking/firewall.nix
@@ -264,7 +264,7 @@ in
                      message = "This kernel does not support disabling conntrack helpers"; }
                  ];
 
-    systemd.services.firewall =
+    systemd.services.firewall = rec
       { description = "Firewall";
 
         wantedBy = [ "network.target" ];
@@ -277,8 +277,12 @@ in
         # better have all necessary modules already loaded.
         unitConfig.ConditionCapability = "CAP_NET_ADMIN";
 
-        serviceConfig.Type = "oneshot";
-        serviceConfig.RemainAfterExit = true;
+        reloadIfChanged = true;
+
+        serviceConfig = {
+          Type = "oneshot";
+          RemainAfterExit = true;
+        };
 
         script =
           ''
@@ -417,11 +421,17 @@ in
             ip46tables -A INPUT -j nixos-fw
           '';
 
+        reload = ''
+          ${helpers}
+          ip46tables -A INPUT -j DROP
+          ${script}
+          ip46tables -D INPUT -j DROP || true # extraCommands might delete the above rule and cause this to fail
+        '';
+
         postStop =
           ''
             ${helpers}
             ip46tables -D INPUT -j nixos-fw || true
-            #ip46tables -P INPUT ACCEPT
           '';
       };