有一个问题,CC里面有没有奇迹防御力和防御率这个东西

拒绝访问 |
| 百度云加速
请打开cookies.
此网站 () 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(3b3ffb87b0cc507a-ua98).
重新安装浏览器,或使用别的浏览器Linux系统防CC攻击自动拉黑IP增强版Shell脚本 | 张戈博客
博客宗旨 把最实用的经验,分享给最需要的读者,希望每一位来访的朋友都能有所收获!
<span class="tipso_style" id="tip-w" data-tipso=''>
浏览 7662318 次
留言 17197 条
随便挑了些,看你喜欢嘛
关于博客 张戈博客是关注互联网以及分享IT运维工作经验的个人博客,主要涵盖了操作系统运维、实用脚本编程以及博客网站建设等经验教程。我的博客宗旨:把最实用的经验,分享给最需要的读者,希望每一位来访的朋友都能有所收获!--一步,二步,三步,N步,二行脚印
张映 发表于
分类目录: ,
标签:, , , ,
上篇博客说到,httpd请求数过多,apache连接数不够,加大连接数的做法,在受ddos,cc攻击的情况下,最终的结果就是系统资源耗尽,导致死机。
测试服务器,也没有想到会受到攻击,什么防范措施也没有做。装了csf的防火墙,在应对少量ddos,cc攻击的,还是挺管用的,以前也用过apf也挺不错,请参考 。下面记录一下,我是怎么发现攻击,并且是怎么解决的。
1,调整apache的连接,总是会被占满,系统资源消耗的很厉害,测试服务器,没有装监控,nagios,cacti,munin,我的博客里面都有。可以自己搜索一下。
2,查看了一下apache的日志,发现某一个IP,请求某一个php,二天内达到9万多,apache的log做了滚动的,所以说正常情况下,不可能有这么多,并且这是测试服务器。看下图。
下面说一下安装配置过程
一,下载安装
wget /free/csf.tgz
tar -zxvf csf.tgz
sh install.sh
如果报perl模块错误,
yum install perl-libwww-perl perl
测试一下csf
[root@rudder csf]# perl /etc/csf/csftest.pl
Testing ip_tables/iptable_filter...OK
Testing ipt_LOG...OK
Testing ipt_multiport/xt_multiport...OK
Testing ipt_REJECT...OK
Testing ipt_state/xt_state...OK
Testing ipt_limit/xt_limit...OK
Testing ipt_recent...OK
Testing xt_connlimit...OK
Testing ipt_owner/xt_owner...OK
Testing iptable_nat/ipt_REDIRECT...OK
Testing iptable_nat/ipt_DNAT...OK
RESULT: csf should function on this server
二,配置csf
配置文件里面,可配置的东西很多,基本配置就不说了,网上有。在这里说一下,怎么配置防止少量的ddos,cc攻击
1,端口洪水攻击保护
vim /etc/csf/csf.conf
//我做了二处改动,第一处如下
PORTFLOOD = "22;5;300,80;20;5"
1),如果300秒内有5个以上连接到tcp端口22的连接,则至少在发现最后一个数据包300秒后阻止该IP地址访问端口22,即在该阻止被取消前有300秒的"安静" 期。
2), 如果5秒内有20个以上连接到tcp端口80的连接,则至少在发现最后一个数据包5秒后阻止该IP地址访问端口80,即在该阻止被取消前有5秒的"安静" 期
给我感觉是,csf不光有一面墙,墙后面,还有一张网,动态防御。感觉这一点做的比较好。
2,启动csf
[root@rudder ~]# /etc/init.d/csf start
启动时打印出很多信息,查看一下,有没有fatal,以及warning,如果没有。
vim /etc/csf/csf.conf
//第二处如下
TESTING = "0"
//TESTING由1改为0
重启一下csf,[root@rudder ~]# csf -r,重启命令都和apf是一样的。二个基于iptables的防火墙,真的有很多地方相似。
3,启动lfd
[root@rudder ~]# /etc/init.d/lfd start
这个模块,有一个很重要的功能,就是记录下防御的过程。来看一下效果。
lfd log日志
194.28.70.132被阻止四次后,被永久禁止访问了。然后我查了一下,这个IP自动被放到了csf.deny下面去了。
[root@rudder ~]# cat /etc/csf/csf.deny
###############################################################################
# Copyright , Way to the Web Limited
###############################################################################
# The following IP addresses will be blocked in iptables
# One IP address per line
# CIDR addressing allowed with a quaded IP (e.g. 192.168.254.0/24)
# Only list IP addresses, not domain names (they will be ignored)
# Note: If you add the text "do not delete" to the comments of an entry then
# DENY_IP_LIMIT will ignore those entries and not remove them
# Advanced port+ip filtering allowed with the following format
# tcp/udp|in/out|s/d=port|s/d=ip
# See readme.txt for more information regarding advanced port filtering
194.28.70.132 # lfd: (PERMBLOCK) 194.28.70.132 has had more than 4 temp blocks in the last 86400 secs - Mon Mar 11 04:19:14 2013
64.34.253.35 # lfd: (PERMBLOCK) 64.34.253.35 has had more than 4 temp blocks in the last 86400 secs - Mon Mar 11 21:30:09 2013
从官网上找了一些参数说明:
-h, --help Show this message
//显示此消息
-l, --status List/Show iptables configuration
//列出/显示iptables配置
-l6, --status6 List/Show ip6tables configuration //列出/显示ip6ables配置
-s, --start Start firewall rules
//启用防火墙规则
-f, --stop Flush/Stop firewall rules (Note: lfd may restart csf) //清除/停止防火墙规则(注意:lfd可能重新启动csf)
-r, --restart Restart firewall rules //重新启用防火墙规则
-q, --startq Quick restart (csf restarted by lfd) //快速重启(lfd重启csf)
-sf, --startf Force CLI restart regardless of LF_QUICKSTART setting //不顾 LF_QUICKSTART设置,强制CLI重新启动
-a, --add ip Allow an IP and add to /etc/csf/csf.allow //允许一个IP并添加至/etc/csf/csf.allow
-ar, --addrm ip Remove an IP from /etc/csf/csf.allow and delete rule //从/etc/csf/csf.allow 删除一个IP,删除规则
-d, --deny ip Deny an IP and add to /etc/csf/csf.deny //拒绝一个IP并添加至/etc/csf/csf.deny
-dr, --denyrm ip Unblock an IP and remove from /etc/csf/csf.deny //解除对一个IP的阻止并从/etc/csf/csf.deny里删除
-df, --denyf Remove and unblock all entries in /etc/csf/csf.deny //删除并解除对/etc/csf/csf.deny里所有记录的阻止
-g, --grep ip Search the iptables rules for an IP match (incl. CIDR) //查询与某IP匹配的iptables规则(包括 CIDR)
-t, --temp Displays the current list of temp IP entries and their
//TTL显示当前临时IP及其TTL的列表
-tr, --temprm ip Remove an IPs from the temp IP ban and allow list //从临时禁止和允许IP列表删除IPs
-td, --tempdeny ip ttl [-p port] [-d direction]
Add an IP to the temp IP ban list. ttl is how long to
//添加一个IP至临时禁止IP列表,
blocks for (default:seconds, can use one suffix of h/m/d) //ttl是指端口的阻止时间(默认:秒,可以使用一个h/m/d后缀)
Optional port. Optional direction of block can be one of:
//可选端口。阻止方向可以是以下任意一种:进入,传出或进出(默认:进入)
in, out or inout (default:in)
-ta, --tempallow ip ttl [-p port] [-d direction]
Add an IP to the temp IP allow list (default:inout)
//添加一个IP至临时允许IP列表(默认:进出)
-tf, --tempf Flush all IPs from the temp IP entries
//清除所有临时IP记录
-cp, --cping PING all members in an lfd Cluster PINGlfd群的所有成员
-cd, --cdeny ip Deny an IP in a Cluster and add to /etc/csf/csf.deny
//拒绝群里的某个IP,并添加到/etc/csf/csf.deny
-ca, --callow ip Allow an IP in a Cluster and add to /etc/csf/csf.allow
//允许群里的某个IP,并添加到/etc/csf/csf.allow
-cr, --crm ip Unblock an IP in a Cluster and remove from /etc/csf/csf.deny
//解除对群里某个IP的阻止,并从/etc/csf/csf.deny 删除
-cc, --cconfig [name] [value]
Change configuration option [name] to [value] in a Cluster
//将群里的配置选项[name]改为[value]
-cf, --cfile [file] Send [file] in a Cluster to /etc/csf/
//在群里发送[file]至/etc/csf/
-crs, --crestart Cluster restart csf and lfd
//重新启动群csf和lfd
-m, --mail [addr] Display Server Check in HTML or email to [addr] if present //在HTML显示服务器检查或发送邮件至[addr]地址,如果存在的话
-c, --check Check for updates to csf but do not upgrade
//检查csf更新但不更新
-u, --update Check for updates to csf and upgrade if available //检查csf更新并更新,如果可以的话
-uf Force an update of csf //强制更新csf
-x, --disable Disable csf and lfd
//禁用csf和lfd
-e, --enable Enable csf and lfd if previously disabled
//启用之前禁用的csf和lfd
-v, --version Show csf version
//显示csf版本
您可以通过这些选项方便快捷地控制和查看csf。所有的csf配置文件都在/etc/csf/ 里,包括:
csf.conf - 主要配置文件,它有说明每个选项用途的注释
csf.allow - 防火墙始终允许通过的IP和CIDR地址列表
csf.deny - 防火墙始终不允许通过的IP和CIDR地址列表
csf.ignore- lfd应忽略,并且发现后不阻止的IP和CIDR地址列表
csf.*ignore- 列出了lfd应忽略的文件,用户,IP地址的各种文件。具体参见每个文件。
如果修改上述任何文件,您要重新启动csf才能生效。如果您使用命令行选项添加或拒绝IP地址,csf会自动生效。
csf.allow 和csf.deny都可以在列出的IP地址后做评论。该评论必须和IP地址在同一行,否则csf.deny的IP轮换会将其删除。
如果直接编辑the csf.allow或csf.deny 文件,不论是从shell或WHM UI,您都要在IP地址与评论之间插入#,如下:
添加 11.22.33.44 # 因为我不喜欢它们
您也可以在使用the csf -a或csf -d命令时添加评论,不过不是插入 # ,而是:
添加csf -d 11.22.33.44 因为我不喜欢它们
转载请注明作者:海底苍鹰地址:}

我要回帖

更多关于 dnf怪物防御力 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信