TEL:
DDoS deflate 轻松解决网站被 DDOS/CC 攻击
| 发布时间: 2020-04-28 15:29:19 | 1151 次浏览
DDoS deflate 轻松解决网站被 DDOS/CC 攻击

DDoS deflate 是一个轻量级的 bash shell 脚本,每分钟会自动检测一次 IP 连接状况,当某些 IP 连接超过脚本设置好的阈值,程序会自动禁止这些 IP 一段时间,以达到防御攻击协助用户阻止 DDOS 攻击的目的。

这可能是目前在软件层面上的简单和最容易安装的解决方案之一

当然了还是建议站长门无论你的服务器是否被攻击,建议安装脚本,以防范于未然

使用CDN 加速的网站不适合用下面脚本,CDN 节点缓存服务器 IP 百分百会被封掉


安装方法:

1、通过工具链接服务器如: putty、Xshell 登陆服务器,输入下面安装命令:

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


2、因为这个脚本是轻量级的,下载安装速度非常快。基本上几秒钟就搞定。安装完以后,你会看到一份协议,按 q 退出即可。

3、安装后文件目录地址为:/usr/local/ddos/

目录下总共四个文件分别为:

(3-1)ddos.conf:
DDoS-Deflate 的配置文件,其中配置防止ddos时的各种行为
(3-2)ddos.sh:
DDoS-Deflate 的主程序,使用shell编写的,整个程序的功能模块
(3-3)ignore.ip.list:
白名单,该文件中的ip超过设定的连接数时,也不被 DDoS-Deflate 阻止
(3-4)LICENSE:
DDoS-Deflate 程序的发布协议
使用教程

安装完成以后打开配置文件可以看到有简洁的说明。

下面是中文对照,大家可以根据自己的服务器情况进行修改。

##### 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
#####检查时间间隔,默认1分钟。一般不用修改 
 
##### How many connections define a bad IP? Indicate that below. 
NO_OF_CONNECTIONS=150
#####单IP发起连接数阀值,达到这个数值IP就被拦截。不建议设置太低。
 
##### 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=1
#####一般情况下使用iptables来做防火墙,所以这里你需要将APF_BAN的值改为0。
 
##### 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=”mikelin@wanlins.com” 
#####这里是邮箱,可以替换成你自己的邮箱。
 
##### Number of seconds the banned ip should remain in blacklist. 
BAN_PERIOD=600
#####设置被挡IP多少秒后移出黑名单。


4、卸载命令:

wget http://www.inetbase.com/scripts/ddos/uninstall.ddos

chmod 0700 uninstall.ddos
./uninstall.ddos