DDoS deflate是一款免费的用来防御和减轻 DDoS***的脚本。它通过netstat监测跟踪创建大量网络连接的IP地址,在检测到某个结点超过预设的限制时,该程序会通过APF或IPTABLES禁止或阻挡这些IP.
确认是否受到 DDOS***的命令:
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n执行后,将会显示服务器上所有的每个 IP多少个连接数。
1.   安装 DDoS deflate .
 
#弹出版权信息后 ,键入 q , 即可退出版权信息.
2. 配置 DDoS deflate .
安装成功后会提示配置文件在 /usr/local/ddos/ddos.conf,所以你可以在ddos.conf里进行简要配置.
vi /usr/local/ddos/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" //白名单
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
#ddos.sh执行的频率 ,单位是分钟,搭配crontab来执行.
如果你更改了该设置,请执行 /usr/local/ddos/ddos.sh –cron
检测时间,默认为1分钟
----------------------------------------------------------------------------
##### How many connections define a bad IP? Indicate that below.
NO_OF_CONNECTIONS=150
#当哪个 IP的连接数达到150就加入黑名单;查看连接数你可以执行
#netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
----------------------------------------------------------------------------
##### 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=0
#一般情况下你是使用 iptables来做防火墙,所以这里你需要将APF_BAN的值改为0.
----------------------------------------------------------------------------
##### KILL=0 (Bad IPs are'nt banned, good for interactive execution of script)
##### KILL=1 (Recommended setting)
KILL=1
#是否屏蔽 IP,将非法的的IP加入iptables的INPUT链中,DROP之.
----------------------------------------------------------------------------
##### An email is sent to the following address when an IP is banned.
##### Blank would suppress sending of mails
EMAIL_TO="root"
#给用户发一封邮件

----------------------------------------------------------------------------
##### Number of seconds the banned ip should remain in blacklist.
BAN_PERIOD=600
#禁用IP链接的的时长
3. 卸载 DDoS deflate ,如果你不想用.
wget http://www.inetbase.com/scripts/ddos/uninstall.ddos
chmod 700 uninstall.ddos
./uninstall.ddos

0

收藏

forevercxr

44篇文章,25W+人气,0粉丝