Firewall (iptables):
Code:
...
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j LOG --log-prefix "iptables: DROP: "
iptables -A INPUT -p tcp --dport 22 -j DROP
...
fail2ban filter:
Code:
[Definition]
failregex = iptables: DROP: .* SRC=(?P<host>\S*) DST.*
ignoreregex =
fail2ban jail config:
Code:
[ssh-22]
enabled = true
filter = ssh-22
action = iptables[name=SSH-22, port=22, protocol=tcp]
sendmail-whois[name=SSH-22, dest=root]
logpath = /var/log/iptables.log
maxretry = 1
bantime = 86400
What I'll probably do though is to put the iptables log at the end of teh valid input chain and not assigned to any port, so that I can ban anything that touches any port other than active enabled services. IMHO this should break any portscan attempt assuming they start at lower ports and work upwards.