Das Recent-Modul von iptables/Netfilter ist sehr nützlich, wenn es darum geht Brute-Force-Attacken abzufangen, die zum Beispiel gegen SSH gerichtet sind und dabei hauptsächlich die Logs vollmüllen.
Dieses Ziel erreicht man beispielsweise mit dem folgenden Codeschnippsel1):
#setup ssh chain ${iptables} -A ssh --protocol tcp --destination ${own_ip} \ --destination-port 22 --match state --state ! NEW,INVALID \ --jump RETURN ${iptables} -A ssh --protocol tcp --destination ${own_ip} \ --destination-port 22 --match state --state NEW,INVALID \ --match recent --name ssh --update --seconds 90 --hitcount 4 \ --match limit --limit 2/minute \ --jump LOG --log-prefix "ssh_brute_force " ${iptables} -A ssh --protocol tcp --destination ${own_ip} \ --destination-port 22 --match state --state NEW,INVALID \ --match recent --name ssh --update --seconds 90 --hitcount 4 \ --jump REJECT --reject-with tcp-reset ${iptables} -A ssh --protocol tcp --destination ${own_ip} \ --destination-port 22 --match state --state NEW,INVALID \ --match recent --name ssh --set --jump RETURN
Einige weitere Beispiele finden sich auf der Homepage des Autors.