Skip to content

Instantly share code, notes, and snippets.

@okdas
Created April 2, 2015 09:54
Show Gist options
  • Save okdas/4567528ab0f2f995b5fc to your computer and use it in GitHub Desktop.
Save okdas/4567528ab0f2f995b5fc to your computer and use it in GitHub Desktop.
desc 'temp task'
task :temp_task do
on roles(:app) do
execute "service iptables-persistent restart &"
%w{10. 11. 12. 16. 17. 20. 21. 22. 23. 24. 25. 31. 32. 50. panel.}.push('').each do |host|
begin
host = Resolv.getaddress "#{host}flyspring.net"
execute "iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED --source #{host} -p tcp --dport 25465 -j ACCEPT"
rescue Resolv::ResolvError
end
end
execute 'iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 25465 -j REJECT'
# execute "iptables-save | awk ' !x[$0]++' > ~/iptables-tmp && iptables-restore < ~/iptables-tmp"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment