wiki:control_traffic_by_port_number
Table of Contents
Control traffic by port number
Something like this should do the job, using the connlimit module of iptables.
iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp --dport 80 -m state \ --state RELATED,ESTABLISHED -j ACCEPT
Adjust “–connlimit-above NN” to limit the maximum connections per IP that you need.
iptables -t filter -I INPUT -p tcp --syn --dport 80 -m connlimit \ --connlimit-above 10 --connlimit-mask 32 -j DROP
Adjust “–connlimit-above NNN” to the maximum total connections you want your web server to support
iptables -t filter -I INPUT -p tcp --syn --dport 80 -m connlimit \ --connlimit-above 150 -j DROP
See also
References
wiki/control_traffic_by_port_number.txt · Last modified: 2021/01/11 14:08 by antisa