Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!/bin/bash
  2. set -x
  3.  
  4. # 1. Delete all existing rules
  5. iptables -F
  6. iptables -t nat -F
  7.  
  8. # 2. Set default chain policies
  9. iptables -P INPUT DROP
  10. iptables -P FORWARD DROP
  11.  
  12. # 3. Allow incoming SSH
  13. iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
  14. iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  15.  
  16. # 4. Allow incoming HTTP
  17. iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
  18. iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
  19.  
  20. # 5. Forward 25565 to Resolving Connector Server
  21. iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 25565 -j DNAT --to-destination 172.16.0.116:25565
  22. iptables -A FORWARD -p tcp -d 172.16.0.116 --dport 25565 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
  23.  
  24. # 6. Block SSH after 3 wrong passwords
  25. iptables -N SSH_CHECK
  26. iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_CHECK
  27. iptables -A SSH_CHECK -m recent --set --name SSH
  28. iptables -A SSH_CHECK -m recent --update --seconds 60 --hitcount 4 --name SSH -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement