iptables.rules 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. *filter
  2. # accept established connections
  3. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  4. # accept local traffic
  5. -A INPUT -i lo -j ACCEPT
  6. -A OUTPUT -o lo -j ACCEPT
  7. # accept ping
  8. -A INPUT -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
  9. # accept ssh with rate limiting
  10. -N LOGREJECTSSH
  11. -A LOGREJECTSSH -j LOG --log-prefix "iptables deny: " --log-level 7
  12. -A LOGREJECTSSH -j REJECT
  13. -A INPUT -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -m recent --set --name SSH --rsource
  14. -A INPUT -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 4 --name SSH --rttl --rsource -j LOGREJECTSSH
  15. -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
  16. # drop invalid
  17. -A INPUT -m conntrack --ctstate INVALID -j DROP
  18. # reject all others (linux compliant blacklist)
  19. -A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
  20. -A INPUT -p tcp -j REJECT --reject-with tcp-rst
  21. -A INPUT -j REJECT --reject-with icmp-proto-unreachable
  22. # drop forwards
  23. -A FORWARD -j DROP
  24. COMMIT