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 }
8 define ip-osm-addresses = { <%= Array(@hosts["inet"]).sort.join(", ") %> }
9 define ip6-osm-addresses = { <%= Array(@hosts["inet6"]).sort.join(", ") %> }
24 <%- node[:networking][:firewall][:sets].each do |set| %>
26 <%- if set.end_with?("-ip") %>
28 <%- elsif set.end_with?("-ip6") %>
36 limit rate 1/second log
40 chain log-and-reject {
41 limit rate 1/second log
46 ip saddr { $ip-private-addresses } jump log-and-drop
47 ip6 saddr { $ip6-private-addresses } jump log-and-drop
49 ip saddr @ip-blacklist jump log-and-drop
50 ip6 saddr @ip6-blacklist jump log-and-drop
52 ct state { established, related } accept
54 icmp type { destination-unreachable } accept
55 icmpv6 type { nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert } accept
57 icmp type { echo-request } limit rate 1/second accept
58 icmpv6 type { echo-request } limit rate 1/second accept
60 meta l4proto { icmp, icmpv6 } jump log-and-drop
62 <%- node[:networking][:firewall][:incoming].uniq.each do |rule| %>
70 ip daddr { $ip-private-addresses } jump log-and-drop
71 ip6 daddr { $ip6-private-addresses } jump log-and-drop
73 <%- node[:networking][:firewall][:outgoing].each do |rule| %>
81 type filter hook input priority filter;
83 iif { $external-interfaces } jump incoming
89 type filter hook forward priority filter;
91 iif { $external-interfaces } jump incoming
92 oif { $external-interfaces } jump outgoing
98 type filter hook output priority filter;
100 oif { $external-interfaces } jump outgoing
105 <%- if node[:roles].include?("gateway") %>
109 type nat hook postrouting priority srcnat;
111 <%- node.interfaces(:role => :external).each do |external| %>
112 <%- node.interfaces(:role => :internal).each do |internal| %>
113 oif { < %= external[:interface] %> } ip saddr { <%= internal[:network] %>/<%= internal[:prefix] %> } snat <%= external[:address] %>