DDoS deflate–简单解决VPS被DDOS/CC攻击
时间:2014-02-22 01:54 来源:未知 作者:admin
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
chmod0700 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
chmod0700 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
(责任编辑:IT)
查看/usr/local/ddos/ddos.sh文件的第117行
修改为以下代码即可!
卸载
白名单设置
有时候默认的白名单经常有失误,为了避免这个情况,我们可以手工设置白名单的ip,然后强制不允许修改
常见问题
|