I set up a server as a socks5 proxy.
I'd like restrict the maximum number(1 or 5 or 20) independent IP connection on specific port at the same time.
I have searched on google, only see some articles like Iptables Limits Connections Per IP(talk about Limit SSH Connections Per IP / Host) or Limit maximum incoming connections to a port using iptables and so on.
They all use iptables connlimit moudle
, just limit the number of connections on a port (one IP can have several connections, but do not restrict the amount of ip, no use)
So these do not fit my need.
update
Let me explain my purpose more accurately.
I want a port only allow a fixed number(1 or 5 or 20) of IP to connect.Not limit connection from per IP.
I think there may be many way to do this.
First thing I thought is iptables, but it seems not capable to my job(I don't know, maybe someone can use iptables achieve my goal, so I ask this question).
I have thought another way too.I can use a program monitor every port, if it find a port which connection IP number exceed the preset value
, then it shut down the extra connections to keep current IP number equal or less preset value
.But I don't know which program can do this.
It's welcome if you have another approach to solve my problem. Just not be trapped by iptables.