使用iptables,如何限制IP范围和浏览器字符串的连接?

时间:2018-09-18 02:15:22

标签: linux iptables web-application-firewall

每天一次,以下IP范围每秒发送多个请求。在攻击过程中,使用了一种奇怪的浏览器,如下所述:

IP Range: 192.168.1.100-192.168.1.200
Port: 80 (Apache web server)   
Browser Name: X11: Crawler

在其他时候,我收到来自提到的IP愤怒的合法流量(使用其他浏览器)。因此,我无法完全阻止此IP范围。

我想将总连接(仅提到的IP范围)限制为15 /分钟。以下iptable规则正确吗?

iptables -A INPUT -p tcp --syn  --dport 80    
-m string    --algo bm --string "X11: Crawler"  \    
-m iprange   --src-range 192.168.1.100-192.168.1.200  \    
-m connlimit --connlimit-above 15/minute --connlimit-mask 32  \    
-j REJECT --reject-with tcp-reset 

1 个答案:

答案 0 :(得分:0)

我认为这可行

iptables -A INPUT -p tcp --destination-port 80 -m iprange --src-range 192.168.1.100-192.168.1.200 -j ACCEPT

如果要禁止IP范围更改,请使用DROP接受