From 753b5776963ed2cbb6980a1f678565469868cf0f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 4 Mar 2023 15:32:38 +0000 Subject: [PATCH] Limit echo on a per source basis --- .../networking/templates/default/nftables.conf.erb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cookbooks/networking/templates/default/nftables.conf.erb b/cookbooks/networking/templates/default/nftables.conf.erb index 63bcb908b..13e070569 100644 --- a/cookbooks/networking/templates/default/nftables.conf.erb +++ b/cookbooks/networking/templates/default/nftables.conf.erb @@ -30,6 +30,16 @@ table inet filter { flags dynamic } + set limit-icmp-echo-ip { + type ipv4_addr + flags dynamic + } + + set limit-icmp-echo-ip6 { + type ipv6_addr + flags dynamic + } + <%- node[:networking][:firewall][:sets].each do |set| %> set <%= set %> { <%- if set.end_with?("-ip") %> @@ -61,11 +71,11 @@ table inet filter { ct state { established, related } accept icmp type { destination-unreachable } accept - icmp type { echo-request } limit rate 1/second accept + icmp type { echo-request } add @limit-icmp-echo-ip { ip saddr limit rate 1/second } accept icmp type { echo-request } drop icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept - icmpv6 type { echo-request } limit rate 1/second accept + icmpv6 type { echo-request } add @limit-icmp-echo-ip6 { ip6 saddr limit rate 1/second } accept icmpv6 type { echo-request } drop meta l4proto { icmp, icmpv6 } jump log-and-drop -- 2.39.5