summary refs log tree commit diff
path: root/modules/services/networking/firewall.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2011-04-12 11:25:57 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2011-04-12 11:25:57 +0000
commite9b2ebcb9920cc86b018f85c2de4adab26b7b27d (patch)
treed6956b8755026c95d1b9ec564fab511c5c66413b /modules/services/networking/firewall.nix
parent22a4047b1b4ca46603d02e6caace768ee00b5e19 (diff)
downloadnixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar.gz
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar.bz2
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar.lz
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar.xz
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.tar.zst
nixpkgs-e9b2ebcb9920cc86b018f85c2de4adab26b7b27d.zip
* Send a TCP RST packet, rather than an ICMP port-unreachable packet,
  for (apparently) open TCP connections that connection tracking 
  doesn't know about.  This prevents TCP connections to this machine
  from hanging in CLOSE_WAIT for a long time.

svn path=/nixos/trunk/; revision=26802
Diffstat (limited to 'modules/services/networking/firewall.nix')
-rw-r--r--modules/services/networking/firewall.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/services/networking/firewall.nix b/modules/services/networking/firewall.nix
index a8dd253d70b..50790ba3135 100644
--- a/modules/services/networking/firewall.nix
+++ b/modules/services/networking/firewall.nix
@@ -147,7 +147,15 @@ in
               ip46tables -A FW_REFUSE -j LOG --log-level info --log-prefix "rejected packet: "
             ''}
 
-            ip46tables -A FW_REFUSE -j ${if cfg.rejectPackets then "REJECT" else "DROP"}
+            ${if cfg.rejectPackets then ''
+              # Send a reset for existing TCP connections that we've
+              # somehow forgotten about.  Send ICMP "port unreachable"
+              # for everything else.
+              ip46tables -A FW_REFUSE -p tcp ! --syn -j REJECT --reject-with tcp-reset
+              ip46tables -A FW_REFUSE -j REJECT
+            '' else ''
+              ip46tables -A FW_REFUSE -j DROP
+            ''}
 
 
             # Accept all traffic on the loopback interface.