M
M
MisterXGYT2021-12-22 21:48:00
iptables
MisterXGYT, 2021-12-22 21:48:00

Need help with iptables. Who can help?

How can 701 ports the first two undefined IP addresses allow access the rest are blocked.
And 1 minutes later this rule is automatically deleted and again 3 and the rest of the IP address is blocked. How to do this please help!
This is done by iptables.

701 port only allows two connections. This is needed for shadowsock vpn server. I created one vpn server on port 701 and it only needs two connections, the others are not needed. I create a server there 20 connections. I only wanted 2. This two should be the first 2 connected.

61c46468240e7654575782.jpeg
It should be such only 2 user.

Not like this: 61c464fa1c3dd872738008.jpeg
Rules should automatically block 3 and the rest.
I can even pay money for a solution. Write to telegram @ShadowsockTM

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Turnaviotov, 2021-12-22
@foxmuldercp

Please rewrite the question more correctly. most likely you need something more "smart", like fail2ban, or something of your own on a shell script + regular scheduler

M
Maxim Grishin, 2021-12-23
@vesper-bot

More or less like this:

iptables -A INPUT -m limit --limit 2/min -p tcp --dport 701 --syn -j ACCEPT

It will work correctly if the default policy on INPUT is DROP or there is a REJECT rule at the end of the list to reject new connections that exceed the specified limit. Details on using the limit module HERE .
Upd: he wants "total" active connections per port to be 2 or less. This is solved using the connlimit module, something like this:
iptables -I INPUT 1 -m tcp --syn --dport 701 -m connlimit --connlimit-mask 0 --connlimit-above 2 -j REJECT

Here 2 is the limit on the number of simultaneous connections, and 0 is the limit applied to all IP addresses in general (only connections from one host are checked by default). To work, it is required that new connections are skipped AFTER this rule, so I wrote to insert the rule at the beginning of the table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question