?this
1
|
netstat
-ntu |
awk
'{print $5}'
|
cut
-d: -f1 |
sort
|
uniq
-c |
sort
-n
|
?代理
1
2
3
|
wget http:
//www
.inetbase.com
/scripts/ddos/install
.sh
chmod
0700
install
.sh
.
/install
.sh
|
ddos.conf ? DDoS-Deflate 的配置文件,其中配置防止ddos時的各類行爲
ddos.sh ? DDoS-Deflate 的主程序,使用shell編寫的,整個程序的功能模塊
ignore.ip.list ? 白名單,該文件中的ip超過設定的鏈接數時,也不被 DDoS-Deflate 阻止
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.如何判斷是否生效
使用web壓力測試,本身攻擊本身,詳細文章,過幾天會介紹
2.從新啓動VPS腳本會自動運行嗎?
會自動運行
3.運行必要軟件是什麼
iptables和sendmail 安裝方法 yum install iptables或sendmail sendmail能夠不裝。
4.怎麼查看被屏蔽IP
若是屏蔽後,請用iptables -L -n 命令查看被屏蔽的IP