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 <%- node[:networking][:firewall][:sets].each do |set| %>
35 <%- if set.end_with?("-ip") %>
37 <%- elsif set.end_with?("-ip6") %>
45 limit rate 1/second log
49 chain log-and-reject {
50 limit rate 1/second log
55 ip saddr { $ip-private-addresses } jump log-and-drop
56 ip6 saddr { $ip6-private-addresses } jump log-and-drop
58 ip saddr @ip-blacklist jump log-and-drop
59 ip6 saddr @ip6-blacklist jump log-and-drop
61 ct state { established, related } accept
63 icmp type { destination-unreachable } accept
64 icmp type { echo-request } limit rate 1/second accept
65 icmp type { echo-request } drop
67 icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept
68 icmpv6 type { echo-request } limit rate 1/second accept
69 icmpv6 type { echo-request } drop
71 meta l4proto { icmp, icmpv6 } jump log-and-drop
73 <%- node[:networking][:firewall][:incoming].uniq.each do |rule| %>
81 ip daddr { $ip-private-addresses } jump log-and-drop
82 ip6 daddr { $ip6-private-addresses } jump log-and-drop
84 <%- node[:networking][:firewall][:outgoing].each do |rule| %>
92 type filter hook input priority filter;
94 iif { $external-interfaces } jump incoming
100 type filter hook forward priority filter;
102 iif { $external-interfaces } jump incoming
103 oif { $external-interfaces } jump outgoing
109 type filter hook output priority filter;
111 oif { $external-interfaces } jump outgoing
116 <%- if node[:roles].include?("gateway") %>
120 type nat hook postrouting priority srcnat;
122 <%- node.interfaces(:role => :external).each do |external| %>
123 <%- node.interfaces(:role => :internal).each do |internal| %>
124 oif { < %= external[:interface] %> } ip saddr { <%= internal[:network] %>/<%= internal[:prefix] %> } snat <%= external[:address] %>