summary refs log tree commit diff
path: root/nixos/modules/services/networking/firewall.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-03-14 14:55:30 -0400
committerShea Levy <shea@shealevy.com>2014-03-14 14:55:30 -0400
commita0d574f19b2ea3fecb539842ea9d64aca861f085 (patch)
treead1d9941c949d4b36dbd7c4d38ab0582ef3037bd /nixos/modules/services/networking/firewall.nix
parent50d144278d6cde36592a1bd30569a52d520ad8b0 (diff)
downloadnixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar.gz
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar.bz2
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar.lz
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar.xz
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.tar.zst
nixpkgs-a0d574f19b2ea3fecb539842ea9d64aca861f085.zip
firewall: Allow setting rate limits for pings
Diffstat (limited to 'nixos/modules/services/networking/firewall.nix')
-rw-r--r--nixos/modules/services/networking/firewall.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/firewall.nix b/nixos/modules/services/networking/firewall.nix
index babde3e942b..07e05fa6d05 100644
--- a/nixos/modules/services/networking/firewall.nix
+++ b/nixos/modules/services/networking/firewall.nix
@@ -171,6 +171,17 @@ in
         '';
     };
 
+    networking.firewall.pingLimit = mkOption {
+      default = null;
+      type = types.nullOr (types.separatedString " ");
+      description =
+        ''
+          If pings are allowed, this allows setting rate limits
+          on them. If non-null, this option should be in the form
+          of flags like "-limit 1/minute -limit-burst 5"
+        '';
+    };
+
     networking.firewall.checkReversePath = mkOption {
       default = kernelHasRPFilter;
       type = types.bool;
@@ -375,7 +386,9 @@ in
 
             # Optionally respond to ICMPv4 pings.
             ${optionalString cfg.allowPing ''
-              iptables -A nixos-fw -p icmp --icmp-type echo-request -j nixos-fw-accept
+              iptables -A nixos-fw -p icmp --icmp-type echo-request ${optionalString (cfg.pingLimit != null)
+                "-m limit ${cfg.pingLimit} "
+              }-j nixos-fw-accept
             ''}
 
             # Accept all ICMPv6 messages except redirects and node