I want to limit the number of ALL incoming NEW connections on a port, not only from one IP, something like:
iptables -I INPUT -p tcp --dport 22 -m state --state NEW -m limit --limit 3/s -j DROP
But I don't understand what's wrong. It worked once/twice, tried different limits and after that it now drops all new connections. (yes, I flushed the iptables each time before adding the rule in its various forms).
EDIT1: I have tried
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 5 --hitcount 5 --name SSH -j DROP
and it seems to work. Will this affect all connections or only the ones from the same IP?
"; } And it *instantly* creates 10 connections, when it should have created only 3 per second, right? – Shocker Apr 10 '12 at 14:49