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 set ip-osm-addresses {
13 elements = { <%= Array(@hosts["inet"]).sort.join(", ") %> }
16 set ip6-osm-addresses {
18 elements = { <%= Array(@hosts["inet6"]).sort.join(", ") %> }
31 <%- node[:networking][:firewall][:sets].each do |set| %>
33 <%- if set.end_with?("-ip") %>
35 <%- elsif set.end_with?("-ip6") %>
43 limit rate 1/second log
47 chain log-and-reject {
48 limit rate 1/second log
53 ip saddr { $ip-private-addresses } jump log-and-drop
54 ip6 saddr { $ip6-private-addresses } jump log-and-drop
56 ip saddr @ip-blacklist jump log-and-drop
57 ip6 saddr @ip6-blacklist jump log-and-drop
59 ct state { established, related } accept
61 icmp type { destination-unreachable } accept
62 icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept
64 icmp type { echo-request } limit rate 1/second accept
65 icmpv6 type { echo-request } limit rate 1/second accept
67 meta l4proto { icmp, icmpv6 } jump log-and-drop
69 <%- node[:networking][:firewall][:incoming].uniq.each do |rule| %>
77 ip daddr { $ip-private-addresses } jump log-and-drop
78 ip6 daddr { $ip6-private-addresses } jump log-and-drop
80 <%- node[:networking][:firewall][:outgoing].each do |rule| %>
88 type filter hook input priority filter;
90 iif { $external-interfaces } jump incoming
96 type filter hook forward priority filter;
98 iif { $external-interfaces } jump incoming
99 oif { $external-interfaces } jump outgoing
105 type filter hook output priority filter;
107 oif { $external-interfaces } jump outgoing
112 <%- if node[:roles].include?("gateway") %>
116 type nat hook postrouting priority srcnat;
118 <%- node.interfaces(:role => :external).each do |external| %>
119 <%- node.interfaces(:role => :internal).each do |internal| %>
120 oif { < %= external[:interface] %> } ip saddr { <%= internal[:network] %>/<%= internal[:prefix] %> } snat <%= external[:address] %>