-
Notifications
You must be signed in to change notification settings - Fork 29
How to limit number of connections per IP
If you want to limit the number of simultaneous connections per IP address, you can use this method based on iptables
.
Note that it limits the connections at the system level. Some players may be legitimately sharing a single IP address and may be impacted. Others may be able to use "proxies" or other tools to evade this limit.
Set a limit at runtime (this alone does not persist across reboots):
sudo iptables -A INPUT -p tcp --syn --dport 7172 -m connlimit --connlimit-above 3 -j REJECT
The limit above is 3 connections per IP. The port the limit applies to is the game port, which is where a persistent connection is maintained. There is no need to limit persistent connection to the login server (port 7171) as these are short lived.
In order for the iptables
rule to service across server reboots, you have to "save" it.
# answer YES if it asks whether you want to save current rules
sudo apt install -y iptables-persistent
# if it doesn't ask to save current rules, use this:
sudo iptables-save > /etc/iptables/rules.v4
Powered by Spigu.net Team | Get OTS Hosting Service with support | Visit our Otland Thread