Skip to content

Instantly share code, notes, and snippets.

@calston
Created September 11, 2012 09:59
Show Gist options
  • Save calston/3697349 to your computer and use it in GitHub Desktop.
Save calston/3697349 to your computer and use it in GitHub Desktop.
Iptables ERB
# Allowed ports
<% if has_variable?("open_ports") then %>
<% open_ports.each do |port| -%>
iptables -t filter -A INPUT -p tcp --dport <%= port %> -j ACCEPT
<% end -%>
<% end %>
<% if has_variable?("open_ports_from") then %>
<% open_ports_from.each_pair do |port, host| -%>
iptables -t filter -A INPUT -p tcp --dport <%= port %> -s <%= host %> -j ACCEPT
<% end -%>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment