老谢博客

  • 首页
  • WordPress
  • 网络技术
  • 乱七八糟
  • 运维技术
  • 给我留言
  • 关于老谢

(D)DoS Deflate 防御简单DDOS攻击

分类:运维技术日期:2012-02-23 - 11:03:23作者:老谢

前言:

互联网如同现实社会一样充满钩心斗角,网站被DDOS也成为站长最头疼的事。在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables,但是iptables不能在自动屏蔽,只能手动屏蔽。今天要说的就是一款能够自动屏蔽DDOS攻击者IP的软件:DDoS Deflate。

(D)Dos官方地址:http://deflate.medialayer.com/

(D)DoS Deflate is a lightweight bash shell script designed to assist in the process of blocking a denial of service attack. It utilizes the command below to create a list of IP addresses connected to the server, along with their total number of connections. It is one of the simplest and easiest to install solutions at the software level.

Installation

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

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

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

文件说明:

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

配置 ddos.conf:

##### 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
 
##### 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

##### 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 ##### 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

找到#echo $CURR_LINE_IP >> $IGNORE_IP_LIST,取消注释

找到netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST,注释掉,换成netstat -ntu | awk ‘{print $5}’ | egrep -o “[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}” | sort | uniq -c | sort -nr > $BAD_IP_LIST

模拟测试:

(D)DoS Deflate 防御简单DDOS攻击

卸载

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

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

原文地址 : https://www.xj123.info/2549.html

本站遵循 : 署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5)

版权声明 : 原创文章转载时,请务必以超链接形式标明文章原始出处

Tags: DDOS , vps 安全
  • 上一篇:让cmd也能查询whois和ip信息
  • 下一篇:Nginx的启动、停止、平滑重启
17条评论
  1. 软件盒子 说:

    此非常实用

    POST:2012-02-23 15:28 回复
  2. 亨sir 说:

    果然够专业哦

    POST:2012-02-23 17:24 回复
  3. suN 说:

    不知道..

    POST:2012-02-23 17:36 回复
  4. 宁波网络推广 说:

    真是管用啊。。。。谢谢博主的分享啊

    POST:2012-02-23 20:36 回复
  5. 鳳梨果凍 说:

    看不懂。。。鴨梨山大啊= =。。。

    POST:2012-02-23 21:23 回复
    • 老谢 说:

      @鳳梨果凍 偶也是现学现卖

      POST:2012-02-24 22:53 回复
  6. 睡着的水 说:

    总是有些无聊人的攻击别人玩啊

    POST:2012-02-24 11:14 回复
    • 老谢 说:

      @睡着的水 无聊的人是蛮多

      POST:2012-02-24 22:54 回复
  7. 自贡SEO 说:

    大师级别的人物。

    POST:2012-02-24 14:46 回复
  8. 大D 说:

    YM专业人士。

    POST:2012-02-24 21:19 回复
    • 老谢 说:

      @大D 果断反YM

      POST:2012-02-24 22:52 回复
  9. SEO博客 说:

    VPS麻烦啊

    POST:2012-02-24 22:42 回复
    • 老谢 说:

      @SEO博客 爱折腾就好~

      POST:2012-02-24 22:51 回复
  10. VPS ROLL 说:

    嘿嘿,受教了。。去安装试试。

    POST:2012-02-26 09:18 回复
  11. zch0071 说:

    我安装后 运行 出现

    ./ddos.sh: 13: [: /usr/local/ddos/ddos.conf: unexpected operator
    DDoS-Deflate version 0.6
    Copyright (C) 2005, Zaf

    $CONF not found.

    POST:2012-06-06 15:19 回复
    • smartweb 说:

      /usr/local/ddos/ddos.conf
      第一行改为
      #!/bin/bash

      POST:2013-12-16 20:53 回复
  12. 鱼里别放刺 说:

    多谢楼主,解决了我看不到攻击者IP地址的问题。

    POST:2014-04-17 13:08 回复
发表评论 点击取消评论.

*必填

*必填

  • 文章归档
  • 子网计算
  • 我的共享
  • 锻炼计划
  • 给我留言
  • 关于老谢
2025 年 6 月
一 二 三 四 五 六 日
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« 5 月    

最新文章

  • 认知,是否是一座大山?当架构决策变成配置清单比价
  • 重装博客服务器环境
  • 特斯拉24款标续 Model Y 2万公里使用体验
  • 接盘的傻子
  • 小牛us电瓶指示灯闪三次不上电
  • 一次还不错的小米售后体验
  • 装台1600元办公主机
  • 2021好久没更新博客
  • Zabbix监控oxidized备份状态
  • Zabbix 5.0 LTS版本MySQL表分区及编译安装随记

最新评论

  • zwwooooo:类似以前做网站开发时,一开始有自...
  • 老陳网志:有点高端,像我们整点nas玩玩就够...
  • springwood:自从 CentOS 不维护之后,我换 U...
  • 大D:难都搞下来了,那就更得YM了
  • 大D:只能是YM了,谢总牛啊
  • 灰常记忆:经济不好 今年我也换了机器 一...
  • 大峰:这是海外服务器嘛?速度挺快的。
  • 大D:只能单走一个6了哈哈哈
  • zwwooooo:买特斯拉和买iPhone的人群其实相似...
  • 平安家属子痕:一直坚持油车,看你写的心里有...

日志存档

  • 2025 年 5 月
  • 2025 年 4 月
  • 2025 年 3 月
  • 2024 年 9 月
  • 2024 年 5 月
  • 2024 年 1 月
  • 2023 年 4 月
  • 2021 年 10 月
  • 2021 年 4 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2020 年 11 月
  • 2020 年 9 月
  • 2020 年 5 月
  • 2020 年 4 月
  • 2020 年 3 月
  • 2020 年 1 月
  • 2019 年 12 月
  • 2019 年 10 月
  • 2019 年 7 月
  • 2019 年 6 月
  • 2019 年 5 月
  • 2019 年 3 月
  • 2019 年 1 月
  • 2018 年 12 月
  • 2018 年 11 月
  • 2018 年 10 月
  • 2018 年 7 月
  • 2018 年 6 月
  • 2018 年 5 月
  • 2018 年 4 月
  • 2018 年 3 月
  • 2018 年 1 月
  • 2017 年 10 月
  • 2017 年 9 月
  • 2017 年 8 月
  • 2017 年 7 月
  • 2017 年 2 月
  • 2017 年 1 月
  • 2016 年 12 月
  • 2016 年 11 月
  • 2016 年 10 月
  • 2016 年 7 月
  • 2016 年 6 月
  • 2016 年 4 月
  • 2016 年 2 月
  • 2016 年 1 月
  • 2015 年 12 月
  • 2015 年 10 月
  • 2015 年 9 月
  • 2015 年 7 月
  • 2015 年 5 月
  • 2015 年 4 月
  • 2015 年 3 月
  • 2015 年 2 月
  • 2015 年 1 月
  • 2014 年 12 月
  • 2014 年 10 月
  • 2014 年 9 月
  • 2014 年 8 月
  • 2014 年 7 月
  • 2014 年 6 月
  • 2014 年 5 月
  • 2014 年 4 月
  • 2014 年 3 月
  • 2014 年 2 月
  • 2014 年 1 月
  • 2013 年 12 月
  • 2013 年 11 月
  • 2013 年 10 月
  • 2013 年 9 月
  • 2013 年 8 月
  • 2013 年 7 月
  • 2013 年 6 月
  • 2013 年 5 月
  • 2013 年 4 月
  • 2013 年 3 月
  • 2013 年 2 月
  • 2013 年 1 月
  • 2012 年 12 月
  • 2012 年 11 月
  • 2012 年 9 月
  • 2012 年 8 月
  • 2012 年 7 月
  • 2012 年 6 月
  • 2012 年 5 月
  • 2012 年 4 月
  • 2012 年 3 月
  • 2012 年 2 月
  • 2012 年 1 月
  • 2011 年 12 月
  • 2011 年 11 月
  • 2011 年 10 月
  • 2011 年 9 月
  • 2011 年 8 月
  • 2011 年 7 月
  • 2011 年 6 月
  • 2011 年 5 月
  • 2011 年 4 月
  • 2011 年 3 月
  • 2011 年 2 月
  • 2011 年 1 月
  • 2010 年 12 月
  • 2010 年 11 月
  • 2010 年 10 月
  • 2010 年 9 月
  • 2010 年 8 月
  • 2010 年 7 月

W3C

  • XHTML 1.0 Transitional
  • CSS level 3
  • Google+
Copyright © 2010-2025 老谢博客 All rights reserved.
Gzipped 76.5% | Optimized loading 50 queries in 0.416 seconds | Memory 38.97 MB | 尼玛的备案
Powered by WordPress. | Hosted By LAOXUEHOST | Theme by WordPress主题巴士 | 站点地图 | SiteMap | uptime查询