how limit the number of open TCP streams from same IP to a local port?

Posted by JMW on Server Fault See other posts from Server Fault or by JMW
Published on 2011-03-13T15:11:34Z Indexed on 2011/03/13 16:11 UTC
Read the original article Hit count: 256

Filed under:
|

Hi,

i would like to limit the number of concurrent open TCP streams from the the same IP to the server's (local) port. Let's say 4 concurrent conncetions.

How can this be done with ip tables?

the closest thing, that i've found was: In Apache, is there a way to limit the number of new connections per second/hour/day?

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 86400 --hitcount 100 -j REJECT

But this limitation just messures the number of new connections over the time. This might be good for controlling HTTP traffic. But this is not a good solution for me, since my TCP streams usually have a lifetime between 5 minutes and 2 hours.

thanks a lot in advance for any reply :)

© Server Fault or respective owner

Related posts about iptables

Related posts about qos