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

相關文章
相關標籤/搜索