Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to Restrict the Number of Parallel Connections Using IPtables?  (Read 2138 times)

0 Members and 1 Guest are viewing this topic.

lijeshk

  • Guest

We can use connlimit module to put such restrictions.

To allow 3 ssh connections per client host, enter:

Code: [Select]
# iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT
Set HTTP requests to 20:

Code: [Select]
# iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 --connlimit-mask 24 -j DROP
Where,

--connlimit-above 3 : Match if the number of existing connections is above 3.

--connlimit-mask 24 : Group hosts using the prefix length. For IPv4, this must be a number between (including) 0 and 32.

--

 :)