3 define external-interfaces = { <%= @interfaces.sort.uniq.join(", ") %> }
5 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 }
6 define ip6-private-addresses = { 2001:db8::/32, fc00::/7 }
11 <%- unless Array(@hosts["inet"]).empty? %>
12 elements = { <%= Array(@hosts["inet"]).sort.join(", ") %> }
16 set ip6-osm-addresses {
18 <%- unless Array(@hosts["inet"]).empty? %>
19 elements = { <%= Array(@hosts["inet6"]).sort.join(", ") %> }
33 set limit-icmp-echo-ip {
38 set limit-icmp-echo-ip6 {
43 <%- node[:networking][:firewall][:sets].each do |set| %>
45 <%- if set.end_with?("-ip") %>
47 <%- elsif set.end_with?("-ip6") %>
55 limit rate 1/second log
59 chain log-and-reject {
60 limit rate 1/second log
65 ip saddr { $ip-private-addresses } jump log-and-drop
66 ip6 saddr { $ip6-private-addresses } jump log-and-drop
68 ip saddr @ip-blacklist jump log-and-drop
69 ip6 saddr @ip6-blacklist jump log-and-drop
71 ct state { established, related } accept
73 icmp type { destination-unreachable } accept
74 icmp type { echo-request } add @limit-icmp-echo-ip { ip saddr limit rate 1/second } accept
75 icmp type { echo-request } drop
77 icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept
78 icmpv6 type { echo-request } add @limit-icmp-echo-ip6 { ip6 saddr limit rate 1/second } accept
79 icmpv6 type { echo-request } drop
81 meta l4proto { icmp, icmpv6 } jump log-and-drop
83 tcp flags fin,psh,urg / fin,syn,rst,psh,ack,urg jump log-and-drop
84 tcp flags ! fin,syn,rst,psh,ack,urg jump log-and-drop
85 tcp flags syn,rst / syn,rst jump log-and-drop
86 tcp flags fin,rst / fin,rst jump log-and-drop
87 tcp flags fin,syn / fin,syn jump log-and-drop
88 tcp flags fin,psh / fin,psh,ack jump log-and-drop
89 tcp sport 0 tcp flags syn / fin,syn,rst,ack jump log-and-drop
91 <%- node[:networking][:firewall][:incoming].uniq.each do |rule| %>
99 ip daddr { $ip-private-addresses } jump log-and-drop
100 ip6 daddr { $ip6-private-addresses } jump log-and-drop
102 <%- node[:networking][:firewall][:outgoing].each do |rule| %>
110 type filter hook input priority filter;
112 iif { $external-interfaces } jump incoming
118 type filter hook forward priority filter;
120 iif { $external-interfaces } jump incoming
121 oif { $external-interfaces } jump outgoing
127 type filter hook output priority filter;
129 oif { $external-interfaces } jump outgoing
134 <%- if node[:roles].include?("gateway") %>
138 type nat hook postrouting priority srcnat;
140 <%- node.interfaces(:role => :external).each do |external| %>
141 <%- node.interfaces(:role => :internal).each do |internal| %>
142 oif { < %= external[:interface] %> } ip saddr { <%= internal[:network] %>/<%= internal[:prefix] %> } snat <%= external[:address] %>