X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/7bcced377bf4a50fc27d6e6fa4d0b180a78807d2..39441034896a48a575b8adb42947b114e62501e8:/cookbooks/networking/templates/default/nftables.conf.erb diff --git a/cookbooks/networking/templates/default/nftables.conf.erb b/cookbooks/networking/templates/default/nftables.conf.erb index 63f45a0c8..f32339e9b 100644 --- a/cookbooks/networking/templates/default/nftables.conf.erb +++ b/cookbooks/networking/templates/default/nftables.conf.erb @@ -2,20 +2,22 @@ define external-interfaces = { <%= @interfaces.sort.uniq.join(", ") %> } -define ip-private-addresses = { 10.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.0.2.0/24, 192.168.0.0/16 } -define ip6-private-addresses = { 2001:db8::/32, fc00::/7 } - -flush ruleset +define ip-private-addresses = { 0.0.0.0, 10.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.0.2.0/24, 192.168.0.0/16, 224.0.0.0/4 } +define ip6-private-addresses = { 2001:db8::/32, fc00::/7, ff00::/8 } table inet filter { set ip-osm-addresses { type ipv4_addr +<%- unless Array(@hosts["inet"]).empty? %> elements = { <%= Array(@hosts["inet"]).sort.join(", ") %> } +<%- end %> } set ip6-osm-addresses { type ipv6_addr +<%- unless Array(@hosts["inet"]).empty? %> elements = { <%= Array(@hosts["inet6"]).sort.join(", ") %> } +<%- end %> } set ip-blacklist { @@ -28,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") %> @@ -59,13 +71,23 @@ table inet filter { ct state { established, related } accept icmp type { destination-unreachable } accept - icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept + icmp type { echo-request } add @limit-icmp-echo-ip { ip saddr limit rate 1/second } accept + icmp type { echo-request } drop - icmp type { echo-request } limit rate 1/second accept - icmpv6 type { echo-request } limit rate 1/second accept + icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } 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 + tcp flags fin,psh,urg / fin,syn,rst,psh,ack,urg jump log-and-drop + tcp flags ! fin,syn,rst,psh,ack,urg jump log-and-drop + tcp flags syn,rst / syn,rst jump log-and-drop + tcp flags fin,rst / fin,rst jump log-and-drop + tcp flags fin,syn / fin,syn jump log-and-drop + tcp flags fin,psh / fin,psh,ack jump log-and-drop + tcp sport 0 tcp flags syn / fin,syn,rst,ack jump log-and-drop + <%- node[:networking][:firewall][:incoming].uniq.each do |rule| %> <%= rule %> <%- end %>