LIMITE IP连接的端口使用iptables,但允许一个IP到unlimitd连接
问题描述:
我需要限制我的Linux服务器上的特定端口同时连接,后来我发现这个iptables规则限制:LIMITE IP连接的端口使用iptables,但允许一个IP到unlimitd连接
的iptables -I INPUT - p tcp --syn --dport 80 -m connlimit --connlimit-above 10 -j DROP
但是我需要知道,如何将IP白名单跳过限制。
见例如:
netstat的-antu | grep:80 | awk'{print $ 5}'| cut -d:-f1 |排序| uniq -c | sort -nr |头-20
406 45.43.xxx.xxx
246 186.249.7.100
118 108.171.138.160
16 200.209.136.11
9 189.125.114.245
8 164.85.83.104
7 108.21.116.86
我需要限制连接为10例如,并允许IP 45.43.xxx.xxx无限连接。
我需要这个端口80,1935年和554
答
像这样的工作:
iptables -s <goodip> ... other stuff ... -j ACCEPT
iptables ... other stuff ... --connlimit-above 10 -j REJECT
它可能比只下降为拒绝。这样,至少,客户端得到通知,连接被拒绝,所以它会停止重试,而不仅仅是“嘿,我从来没有得到对最后一次连接的响应,所以我会再试一次”...
答
这是正确的?
允许IP:
iptables -I INPUT -p tcp -s 000.000.000.000 --syn --dport 80 -m connlimit --connlimit-above 10 -j DROP
拒绝别人限制为10个连接:
iptables -I INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 10 -j DROP