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

相关文章
相关标签/搜索