Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ALLOWED="21 22 80 25565 6379 45700 8087"
  4.  
  5. iptables -P INPUT ACCEPT
  6. iptables -F
  7. iptables -X
  8. iptables -Z
  9.  
  10. iptables -A INPUT -i lo -j ACCEPT
  11. iptables -A OUTPUT -o lo -j ACCEPT
  12.  
  13. for port in $ALLOWED; do
  14. echo "Aceptando el puerto TCP $port..."
  15. iptables -A INPUT -p tcp --dport $port -j ACCEPT
  16. done
  17.  
  18. for port in $ALLOWED; do
  19. echo "Aceptando el puerto UDP $port..."
  20. iptables -A INPUT -p udp --dport $port -j ACCEPT
  21. done
  22.  
  23. iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  24.  
  25. iptables -A INPUT -p udp -j DROP
  26. iptables -A INPUT -p tcp --syn -j DROP
  27. iptables -N syn_flood
  28. iptables -A INPUT -p tcp --syn -j syn_flood
  29. iptables -A syn_flood -m limit --limit 3/s --limit-burst 9 -j RETURN
  30. iptables -A syn_flood -j DROP
  31. iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
  32. iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG
  33. iptables -A INPUT -p tcp --syn --dport 25565 -m connlimit --connlimit-above 3 -j REJECT
  34.  
  35. ufw allow 20
  36. ufw allow 21
  37. ufw allow 22
  38. ufw allow 80
  39. ufw allow 25565
  40. ufw enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement