?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