为iptables增加connlimit模块 限制DOS攻击


注:2.6.23以前的内核版本默认不支持 connlimit

推荐规则

iptables -A INPUT -p tcp -m tcp -m connlimit --dport 80 --tcp-flags SYN,ACK,FIN,RST SYN -j DROP --connlimit-above 32 --connlimit-mask 32
如果/var/logs/message出现

ipt_connlimit: Oops: invalid ct state ?

在这条规则前面加一条

iptables -A INPUT -m conntrack -j DROP --ctstate INVALID
阻断非法数据包

查看效果

iptables -n -L -v |grep conn
17479 1033K DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 flags:0x17/0x02 #conn/32 > 32

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3