LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > 安全 >

DDoS deflate–简单解决VPS被DDOS/CC攻击

时间:2015-04-13 10:30来源:未知 编辑:linuxeye 点击:
我想现在大家接触VPS久了,也知道互联网上被DDOS,CC是家常便饭,在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables,但是iptables不能在自动屏蔽,只能手动屏蔽,今天
我想现在大家接触VPS久了,也知道互联网上被DDOS,CC是家常便饭,在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables,但是iptables不能在自动屏蔽,只能手动屏蔽,今天我给大家介绍的就是一款可以自动屏蔽DDOS,CC,SYN攻击的软件:DDoS Deflate。

DDoS deflate官方地址:http://deflate.medialayer.com/

DOS DEFLATE是一个轻量级的bash shell脚本,以协助用户阻止DDOS攻击,它利用下面的命令创建一个连接到服务器的IP地址列表,以及与他们连接总数。它是在软件层面上的简单和最容易安装的解决方案之一。

如何查看是否被攻击

在VPS中输入上面的命令查看
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sort |  uniq -c |  sort -n

下面是安装教程
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod +x  install .sh
. /install .sh

安装完以后,你会看到一大篇协议,按q退出即可 :

安装后文件说明 安装目录为:/usr/local/ddos/
  • ddos.conf ? DDoS-Deflate 的配置文件,其中配置防止ddos时的各种行为
  • ddos.sh ? DDoS-Deflate 的主程序,使用shell编写的,整个程序的功能模块
  • ignore.ip.list ? 白名单,该文件中的ip超过设定的连接数时,也不被 DDoS-Deflate 阻止
  • 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 ##### 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行
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sort |  uniq -c |  sort -nr > $BAD_IP_LIST

修改为以下代码即可!
netstat -ntu |  awk '{print $5}' |  cut -d: -f1 |  sed -n  '/[0-9]/p' |  sort |  uniq -c |  sort -nr > $BAD_IP_LIST

卸载
wget http: //www .inetbase.com /scripts/ddos/uninstall .ddos
chmod +x uninstall.ddos
. /uninstall .ddos

白名单设置

有时候默认的白名单经常有失误,为了避免这个情况,我们可以手工设置白名单的ip,然后强制不允许修改
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

转载请保留固定链接: https://linuxeye.com/security/2398.html

------分隔线----------------------------
标签:DDOS
栏目列表
推荐内容