Skip to content

Commit

Permalink
1. Don't allow NAT rules on IPv6 on kernels older that 3.7.
Browse files Browse the repository at this point in the history
2. Don't set up the IPv6 NAT table if no NAT rules are defined.
  • Loading branch information
andrewheald committed Feb 8, 2016
1 parent 0807124 commit 5863d15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions providers/rule.rb
Expand Up @@ -8,6 +8,10 @@
updated |= handle_rule(new_resource, "ipv4")
end
if [:ipv6, :both].include?(new_resource.ip_version)
if new_resource.table == 'nat' &&
Gem::Version.new(/\d+(\.\d+(.\d+)?)?/.match(node['kernel']['release'])[0]) < Gem::Version.new('3.7')
raise "NAT table cannot be used with IPv6 before Kernel 3.7"
end
updated |= handle_rule(new_resource, "ipv6")
end
new_resource.updated_by_last_action(updated)
Expand Down
3 changes: 2 additions & 1 deletion templates/default/ip6tables-rules.erb
@@ -1,4 +1,5 @@
<% if node["simple_iptables"]["ipv6"]["tables"].include?('nat') %>
<% if node["simple_iptables"]["ipv6"]["tables"].include?('nat') &&
node["simple_iptables"]["ipv6"]["rules"]["nat"].size > 0 %>
# This file generated by Chef. Changes will be overwritten.
*nat
:PREROUTING <%= node["simple_iptables"]["ipv6"]["policy"]["nat"]["PREROUTING"] || "ACCEPT" %> [0:0]
Expand Down

0 comments on commit 5863d15

Please sign in to comment.