Answer the question
In order to leave comments, you need to log in
How to limit the number of connections per port in linux?
Hello.
Actually a subject.
There is a service, it spins on a specific port, for example 80.
Is there a way, for example, using iptables, to limit the number of connections to it.
Those. if 6 sessions are now installed (it doesn’t matter from the 1st ip or from the 6th), then the 7th is no longer allowed to connect and drop. And as soon as there are 5 of them again, then a new one can be installed again.
Answer the question
In order to leave comments, you need to log in
iptables -I INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 10 -j DROP
It will be easier to do this using the service.
For a TCP service, you can look for a solution with IPTABLES or using xinetd. The second is even easier:
service test
{
instances = 10 # ограничение в 10 штук
sock_type = stream
protocol = tcp
wait = no
user = root
server = /home/me/bin/testsmpp
redirect = 127.0.0.1 8000
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question