请教关于iptables 防CC的策略。
请教关于iptables 防CC的策略。在网上找到的:
1)控制单个IP的最大并发连接数
iptables -I INPUT -p tcp --dport 80 -m connlimit--connlimit-above 50 -j REJECT #允许单个IP的最大连接数为 30
#默认iptables模块不包含connlimit,需要自己单独编译加载,请参考该地址
http://sookk8.blog.51cto.com/455855/280372不编译内核加载connlimit模块
(2)控制单个IP在一定的时间(比如60秒)内允许新建立的连接数
iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 30 -j REJECT
iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --set -j ACCEPT
#单个IP在60秒内只允许最多新建30个连接
---------------------------------------------------------------------------------------------------------------------------------------
共三行代码。最上和最下面执行都没问题。。。中间的执行提示:iptables: Invalid argument. Run `dmesg' for more information.
是什么情况。谢谢。
本帖最后由 井蛙夏虫 于 2013-07-03 20:34 编辑
回复 1# cnmt
在我的系统上(fedora 16):
man iptables--hitcount hits
This option must be used in conjunction with one of --rcheck or --update. When used, this will narrow thematchtoonlyhappen
whentheaddressis in the list and packets had been received greater than or equal to the given value. This option may be used
along with --seconds to create an even narrower match requiring a certain number of hits within a specific time frame.The maximum
valuefor the hitcount parameter is given by the "ip_pkt_list_tot" parameter of the xt_recent kernel module. Exceeding this value
on the command line will cause the rule to be rejected.
The module itself accepts parameters, defaults shown:
ip_pkt_list_tot=20
Number of packets per address remembered. 回复 2# 井蛙夏虫
请大虾指明。新手。看不懂。
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH --rsource
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 --rttl --name SSH --rsource -j DROP
我的ssh策略 受教了。。。 lolizeppelin 发表于 2013-07-04 14:45 static/image/common/back.gif
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH --rsource
-A INPU ...朋友。我要的是防CC的。 cnmt 发表于 2013-07-05 09:36 static/image/common/back.gif
朋友。我要的是防CC的。
大哥你不会照着改啊?还要我吧端口改成你的啊 lolizeppelin 发表于 2013-07-05 09:48 static/image/common/back.gif
大哥你不会照着改啊?还要我吧端口改成你的啊
你这不是SSH的吗。 --name 这个是随便你自己写的,你想写ssh就ssh,想写其他的就写其他的....
和你后面drop规则里的name对应就可以了 lolizeppelin 发表于 2013-07-05 10:55 static/image/common/back.gif
--name 这个是随便你自己写的,你想写ssh就ssh,想写其他的就写其他的....
和你后面drop规则里的name对应就 ...
好人帮到底。你帮我改一下得了。我存新手。
页:
[1]
2