I use for some time a module called 'limit' to limit the amount of connections per timeunit to my SMTP server. But the limitations I found is that you need to write a rule that matches to apply the filter:
-A INPUT -s 0/0 -d 0/0 -m limit --limit 60/minute --limit-burst 45 -m tcp -p tcp --dport 25 --syn -j SMTPCHAINS
I mean... it is not possible to define something like:
"do no accept more than 60 connections per minute for ANY IP, and, if that limit is reach for some IP, do not limit the rest of connections"
since you can not write a rule for all the possible IPs. I found a (not so good) solution to this... I divided the IPs range in 8 groups:
-A SMTPCHAINS -s 0.0.0.0/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.1/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.2/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.3/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.4/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.5/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.6/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
-A SMTPCHAINS -s 0.0.0.7/0.0.0.7 -d 0/0 -m limit --limit 45/minute --limit-burst 20 -m tcp -p tcp --dport 25 --syn -j ACCEPT
but I stell want something better. I guess that using some kind of connection trucking to know the histoty of connections from each IP could be the solution.
The question is... Is there any module o reluset that achive that?
Thank you very much.... --
Federico Petronio petronio@xxxxxxxxxxx Linux User #129974
--- There are only 10 types of people in the world: Those who understand binary and those who don't.