Created
April 2, 2015 09:54
-
-
Save okdas/4567528ab0f2f995b5fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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