IPTables to limit number of simultaneous connections

Forget Monday Blues !!!

Read a small tip about limiting number of simultaneous connections from a host to a particular service.

We can use IPTables to limit number of simultaneous connections from a host thus reducing unnecessary load on the server.

Here in this example I am limiting number of simultaneous connections to 1 on my server, using IPTables.

iptables -A INPUT -p tcp –syn –dport 22 -m connlimit –connlimit-above 1 -j REJECT

Do remember to save iptables. 🙂

Now if someone tries to establish more than 1 ssh connections to my server, he will be refused.

Below is a systematic screenshot from my machine. To make things clearer to you.

You can see that after applying iptables, the first ssh connection from the host legacy is allowed to server named linuxstorage.. but as he tries to make another connection, he is refused.

Say Thanks to iptables, and do “like” it.

Do “like” Network NUTS Facebook Page.

IPTables to limit number of simultaneous connections

IPTables to limit number of simultaneous connections

Advertisements