3 Star 16 Fork 13

aqztcom / cc_iptables

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ddos2.sh 761 Bytes
一键复制 编辑 原始数据 按行查看 历史
ppabc 提交于 2014-10-16 17:01 . ddos2.sh
#!/bin/sh
##http://www.oschina.net/code/snippet_17_9265
############### KILL DDOS ##############
iptables_log="/data/logs/iptables_conf.log"
### Iptables 配置导出的路径,可任意修改 ###
########################################
status=`netstat -na|awk '$5 ~ /[0-9]+:[0-9]+/ {print $5}'|awk -F ":" -- '{print $1}' |sort -n|uniq -c |sort -n|tail -n 1|grep -v 127.0.0.1`
NUM=`echo $status|awk '{print $1}'`
IP=`echo $status|awk '{print $2}'`
result=`echo "$NUM > 200" | bc`
### 如果同时连接数大于 200 则干掉!###
if [ $result = 1 ]
then
echo IP:$IP is over $NUM, BAN IT!
/sbin/iptables -I INPUT -s $IP -j DROP
fi
########################################
iptables-save > ${iptables_log}
### 输出当前的 iptable 配置作为日志 ###
########################################
Shell
1
https://gitee.com/null_564_0890/cc_iptables.git
git@gitee.com:null_564_0890/cc_iptables.git
null_564_0890
cc_iptables
cc_iptables
master

搜索帮助