HowToLimitSSHScans
From PDP/Grid Wiki
Revision as of 08:02, 21 August 2009 by Davidg@nikhef.nl (talk | contribs)
Add this to the very top of the iptables file
# ssh scanning block -A RH-FW-1-INPUT -p tcp -m state --state NEW --dport 22 -m recent --name sshattack --set -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j LOG --log-prefix "SSH REJECT: " -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j REJECT --reject-with tcp-reset
so that you get
# Firewall configuration manually crafted for XXX *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-FW-1-INPUT - [0:0] :LOCAL-INPUT - [0:0] -A INPUT -j RH-FW-1-INPUT -A FORWARD -j RH-FW-1-INPUT -A RH-FW-1-INPUT -i lo -j ACCEPT # ssh scanning block -A RH-FW-1-INPUT -p tcp -m state --state NEW --dport 22 -m recent --name sshattack --set -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j LOG --log-prefix "SSH REJECT: " -A RH-FW-1-INPUT -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --rcheck --seconds 30 --hitcount 3 -j REJECT --reject-with tcp-reset # related goes through -A RH-FW-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # services that may go through ...