您的位置:首页 > 其它

防止ddos攻击软件 DDoS-Deflate 的安装和使用

2011-10-25 12:42 330 查看
DDoS-Deflate通过查看单个ip的连接数来判断这次连接是否是ddos攻击的一部分,被确定为是ddos攻击时,会调用iptables对该ip进行阻拦一段时间,以缓解攻击。

DDoS-Deflate 的配置很简单明了。

(一)安装DDoS-Deflate

(1)下载安装脚本

wget http://www.inetbase.com/scripts/ddos/install.sh
(2)
安装 DDoS-Deflate

./install.sh
.....下面是安装过程,很快....

Installing DOS-Deflate 0.6

Downloading source files.........done

Creating cron to run script every minute.....(Default setting)

....

下面是发布协议
....

....

这样 DDoS-Deflate,就安装好了

二)配置和使用

(1)
了解 DDoS-Deflate 软件的文件分布

DDoS-Deflate 安装好之后,默认全部在 /usr/local/ddos/ 目录下

# pwd

/usr/local/ddos

# ls

ddos.conf ddos.sh ignore.ip.list LICENSE

文件说明:

ddos.conf -- DDoS-Deflate 的配置文件,其中配置防止ddos时的各种行为

ddos.sh -- DDoS-Deflate 的主程序,使用shell编写的,整个程序的功能模块

ignore.ip.list -- 白名单,该文件中的ip超过设定的连接数时,也不被 DDoS-Deflate 阻止

LICENSE -- DDoS-Deflate 程序的发布协议

(2)
配置 ddos.conf

##### Paths of the script and other files #配置文件也是个shell脚本

PROGDIR="/usr/local/ddos"
PROG="/usr/local/ddos/ddos.sh"
IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list" #存放白名单的文件
CRON="/etc/cron.d/ddos.cron" #计划任务,默认是每分钟执行一次ddos.sh
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

#DDoS-Deflate通过linux的计划任务执行,默认为每分钟一次

d IP? Indicate that below.

NO_OF_CONNECTIONS=150

#定义单个IP达到多少连接时规定为这是一次ddos攻击

##### How many connections define a ba

##### 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=0

#这里为 “0”,表示使用iptables,而不是APF

##### KILL=0 (Bad IPs are'nt banned, good for interactive execution of script)

##### KILL=1 (Recommended setting)

KILL=1

#是否阻止被定义为ddos攻击的ip,“1”为阻止

##### An email is sent to the following address when an IP is banned.

##### Blank would suppress sending of mails

EMAIL_TO=

"xyzblood@163.com"

#事件通知人的邮件地址

##### Number of seconds the banned ip should remain in blacklist.

BAN_PERIOD=600

#阻止被定义为ddos攻击者ip与本机通信时间,默认为600秒

(3)
使用ddos.sh

使用“-h”选项显示该命令的提供的选项和功能简介
因为安装的时候默认就执行了: ./ddos --cron 了,所以我们什么也不需要做了
# ./

ddos.sh
-h

DDoS-Deflate version 0.6

Copyright (C) 2005, Zaf <

zaf@vsnl.com
>

Usage: ddos.sh [OPTIONS]

N : number of tcp/udp connections (default 150)

OPTIONS:

-h
| --help: Show this help screen

-c
| --cron: Create cron job to run this script regularly (default 1 mins)

-k
| --kill: Block the offending ip making more than N connections

(4)
测试防ddos攻击效果

NO_OF_CONNECTIONS=3 #这里为了方便测试,设置为3。生产环境下,几十到几百都可以理解为正常,上千肯定就是不正常了,除非是应用内部各个服务器之间的通信
通过一台固定ip的机器ssh连接该服务器,当连接到超过3甚至更多时,不会立刻显示连不上,因为ddos.sh默认一分钟运行一次,当过不到一分钟时,会发现连接掉了,查看部署了防ddos软件的服务器上可以看到iptables的策略中多了:

DROP all -- 31.210.16.29.broad.cs.gd.dynamic.163data.com.cn anywhere
说明确实生效了,当10分钟后,iptables上这条策略会被取消的

(5)
关于如何查看单个IP的连接数目可以通过如下命令查看,依次排列:

netstat -na|grep ESTABLISHED|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -r -n
..............
40 127.0.0.1

1 121.9.252.28

1 173.117.140.69

(三)后记

ddos攻击很常见,攻击效果也很好,比如像前段时间由于维基创始人引发的那次大范围的攻击。

如果有专门防止ddos的硬件设备的话最好,没有的话就利用DDoS-Deflate结合iptables在一定程度上防范ddos攻击也是一种很好的策略。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: