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

DDoS-Deflate经过查看单个ip的链接数来判断此次链接是不是ddos***的一部分,被肯定为是ddos***时,会调用iptables对该ip进行阻拦一段时间,以缓解***。

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

(一)安装DDoS-Deflate

(1)下载安装脚本
linux

    wget http://www.inetbase.com/scripts/ddos/install.shshell


(2)

安装 DDoS-Deflate服务器



./install.shssh

.....下面是安装过程,很快....tcp


Installing DOS-Deflate 0.6ide




Downloading source files.........done测试



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



....3d

下面是发布协议

....事件


....



这样 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]


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***也是一种很好的策略。

相关文章
相关标签/搜索