Advertisement
Guest User

Untitled

a guest
Jun 17th, 2021
9,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.68 KB | None | 0 0
  1. ### Recommended BASIC IPTables rules for Bungeecord networks ###
  2. # Anything containing 'OPTIONAL' may cause network issues on some server setups. Use at your own risk (Can obviously be removed #
  3.  
  4. ### 1: Drop invalid packets ###
  5. /sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
  6.  
  7. ### 2: Drop TCP packets that are new and are not SYN ###
  8. /sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
  9.  
  10. ### 4: Block packets with bogus TCP flags ###
  11. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
  12. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
  13. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
  14. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
  15. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
  16. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,ACK FIN -j DROP
  17. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,URG URG -j DROP
  18. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,FIN FIN -j DROP
  19. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,PSH PSH -j DROP
  20. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL ALL -j DROP
  21. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
  22. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
  23. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j DROP
  24. /sbin/iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  25.  
  26. ### 7: Drop fragments in all chains ###
  27. /sbin/iptables -t mangle -A PREROUTING -f -j DROP
  28.  
  29. ### 8: Limit connections per source IP ### !!!OPTIONAL, DO NOT USE THIS IF IT CAUSES ISSUES!!!
  30. /sbin/iptables -A INPUT -p tcp -m connlimit --connlimit-above 111 -j REJECT --reject-with tcp-reset
  31.  
  32. ### 9: Limit RST packets ### !!!OPTIONAL, DO NOT USE IF THIS CAUSES ISSUE (Unlikely)!!!
  33. /sbin/iptables -A INPUT -p tcp --tcp-flags RST RST -m limit --limit 2/s --limit-burst 2 -j ACCEPT
  34. /sbin/iptables -A INPUT -p tcp --tcp-flags RST RST -j DROP
  35.  
  36. ### 10: Limit new TCP connections per second per source IP ###
  37. /sbin/iptables -A INPUT -p tcp -m conntrack --ctstate NEW -m limit --limit 30/s --limit-burst 10 -j ACCEPT
  38. /sbin/iptables -A INPUT -p tcp -m conntrack --ctstate NEW -j DROP
  39.  
  40. ### SSH brute-force protection ### (Useful for more then just SSH issues...)
  41. /sbin/iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --set
  42. /sbin/iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 10 -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement