当前位置:首页 > CN2资讯 > 正文内容

防止DDOS攻击

19小时前CN2资讯
DOS-Deflate 是由Zaf开发的脚本,最初是在MediaLayer服务器上使用,以协助管理员解决拒绝服务攻击(DOS)问题.如何防范拒绝服务攻击一直是服务器管理员研究的一个课题,尤其是使用VPS(虚拟服务器)的管理员.由于是在虚拟的环境下,既不好要求服务商增加硬件防火墙,又因为本身虚拟的架构导致了一些内核模块(如:connlimit)无法安装.VPS或者服务器要完全防止拒绝服务攻击是不太现实的,依靠某个模块只能减轻攻击产生的影响,并不能真正杜绝攻击.服务器性能及网络频宽决定了防止攻击的实施难易度.
诡谲在这里推荐VPS(vz)管理员使用DOS-Deflate脚本.通过APF添加动态过滤.脚本安装简单,防范攻击的效果也很不错.但是需要注意,安装前需确定Advanced Policy Firewall (APF)已经在你的系统安装并运行良好.否则将不会起到封禁攻击IP的作用.
安装step by step 1.以root用户登录终端.
2.下载安装脚本
#cd /usr/local/src #wget http://www.inetbase.com/scripts/ddos/
3.安装防护
#sh ./
安装完成之后.可以在/usr/local/ddos/路径找到配置文件和sh脚本.配置十分简单,你只需编辑/usr/local/ddos/ddos.conf文件.
参数配置示范:
##### Paths of the script and other files PROGDIR="/usr/local/ddos" PROG="/usr/local/ddos/ddos.sh" IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list"  # 白名单.如有反向代理,注意添加本机地址和本机外网IP地址,防止提供反向代理的主机被判定为攻击. CRON="/etc/cron.d/ddos.cron" APF="/etc/apf/apf" IPT="/sbin/iptables"
##### frequency in minutes for running the script ##### Caution: Every time this setting is changed, run the script with --cron ##### option so that the new frequency takes effect FREQ=1
##### How many connections define a bad IP? Indicate that below.  # 单IP发起连接数阀值,不建议设置太低. NO_OF_CONNECTIONS=150
##### APF_BAN=1 (Make sure your APF version is atleast 0.96) ##### APF_BAN=0 (Uses iptables for banning ips instead of APF) APF_BAN=1
##### KILL=0 (Bad IPs are'nt banned, good for interactive execution of script) ##### KILL=1 (Recommended setting) KILL=1
##### An email is sent to the following address when an IP is banned.   # 当单IP发起的连接数超过阀值后,将发邮件给指定的收件人. ##### Blank would suppress sending of mails EMAIL_TO="root"
##### Number of seconds the banned ip should remain in blacklist.   # 设置被挡IP多少秒后移出黑名单. BAN_PERIOD=600

此外还要修改两个地方.
1. 在/usr/local/ddos/ddos.sh的第134行.注释掉这行,前面加'#'号
#echo $CURR_LINE_IP >> $IGNORE_IP_LIST
2.在同个文件大概117行处,将netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST注释掉然后在下面添加 netstat -ntu | awk '{print $5}' | egrep -o "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | sort | uniq -c | sort -nr > $BAD_IP_LIST
模拟发起dos攻击后,系统管理员将收到邮件,告知过去1分钟禁止了哪些IP和其发起的连接数.


卸载 以root用户登录终端,下载反安装脚本
#wget http://www.inetbase.com/scripts/ddos/uninstall.ddos #sh ./uninstall.ddos
    你可能想看:

    扫描二维码推送至手机访问。

    版权声明:本文由皇冠云发布,如需转载请注明出处。

    本文链接:https://www.idchg.com/info/19018.html

    分享给朋友:

    “防止DDOS攻击” 的相关文章