DDoS deflate–簡單解決VPS被DDOS/CC攻擊

我想如今你們接觸VPS久了,也知道互聯網上被DDOS,CC是屢見不鮮,在沒有硬防的狀況下,尋找軟件代替是最直接的方法,好比用iptables,可是iptables不能在自動屏蔽,只能手動屏蔽,今天我給你們介紹的就是一款能夠自動屏蔽DDOS,CC,SYN攻擊的軟件:DDoS Deflate。web

DDoS deflate官方地址:http://deflate.medialayer.com/shell

DOS DEFLATE是一個輕量級的bash shell腳本,以協助用戶阻止DDOS攻擊,它利用下面的命令建立一個鏈接到服務器的IP地址列表,以及與他們鏈接總數。它是在軟件層面上的簡單和最容易安裝的解決方案之一。bash

如何查看是否被攻擊服務器

在VPS中輸入上面的命令查看測試

?this

1
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sort |  uniq -c |  sort -n

下面是安裝教程spa

?代理

1
2
3
wget http: //www .inetbase.com /scripts/ddos/install .sh
chmod 0700  install .sh
. /install .sh

安裝完之後,你會看到一大篇協議,按q退出便可 :code

安裝後文件說明 安裝目錄爲:/usr/local/ddos/orm

  1. ddos.conf ? DDoS-Deflate 的配置文件,其中配置防止ddos時的各類行爲

  2. ddos.sh ? DDoS-Deflate 的主程序,使用shell編寫的,整個程序的功能模塊

  3. ignore.ip.list ? 白名單,該文件中的ip超過設定的鏈接數時,也不被 DDoS-Deflate 阻止

  4. LICENSE ? DDoS-Deflate 程序的發佈協議

下面是配置文件的中文說明 你們能夠根據配置文件進行修改,默認也能夠

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##### 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) #通常狀況下你是使用iptables來作防火牆,因此這裏你須要將 APF_BAN的值改成0.
APF_BAN=1
##### KILL=0 (Bad IPs are’nt banned, good for interactive execution of script)
##### KILL=1 (Recommended setting)
KILL=1  // 是否屏蔽IP,默認便可
##### 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

查看/usr/local/ddos/ddos.sh文件的第117行

?

1
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sort |  uniq -c |  sort -nr > $BAD_IP_LIST

修改成如下代碼便可!

?

1
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sed -n  '/[0-9]/p' |  sort |  uniq -c |  sort -nr > $BAD_IP_LIST

卸載

?

1
2
3
wget http: //www .inetbase.com /scripts/ddos/uninstall .ddos
chmod 0700 uninstall.ddos
. /uninstall .ddos


白名單設置

有時候默認的白名單常常有失誤,爲了不這個狀況,咱們能夠手工設置白名單的ip,而後強制不容許修改

?

1
2
3
vi /usr/local/ddos/ignore .ip.list  // 手工設置白名單IP
chattr +i  /usr/local/ddos/ignore .ip.list   // 強制不容許修改
chattr -i  /usr/local/ddos/ignore .ip.list   // 解除不容許修改

常見問題

  1. 1.如何判斷是否生效

  2. 使用web壓力測試,本身攻擊本身,詳細文章,過幾天會介紹

  3. 2.從新啓動VPS腳本會自動運行嗎?

  4. 會自動運行

  5. 3.運行必要軟件是什麼

  6. iptables和sendmail 安裝方法 yum install iptables或sendmail sendmail能夠不裝。

  7. 4.怎麼查看被屏蔽IP

  8. 若是屏蔽後,請用iptables -L -n 命令查看被屏蔽的IP

相關文章
相關標籤/搜索