1 Star 0 Fork 51

miaonotebook / cc_iptables

forked from ppabc / cc_iptables 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nginx_log_cc_iptables.sh 517 Bytes
一键复制 编辑 原始数据 按行查看 历史
ppabc 提交于 2014-10-16 13:38 . update
#!/bin/bash
##email: ppabc#qq.com
##ppabc
tail www.aqzt.com.access.log -n 9999 |awk '{print $1}'|sort|uniq -c|sort -rn|awk '{if ($1>200){print $2}}' > /data/nginxlogs/block_attack_ips.log
/sbin/iptables -nL |grep DROP | awk '{print $4}' > /data/nginxlogs/iptables.log
filename=`cat /data/nginxlogs/block_attack_ips.log`
for ip in $filename
do
if [ `grep $ip /data/nginxlogs/iptables.log` ]
then
echo "Already exists"
else
echo "add"
/sbin/iptables -I INPUT -p tcp -s $ip --dport 80 -j DROP
fi
done
1
https://gitee.com/andmiao/cc_iptables.git
git@gitee.com:andmiao/cc_iptables.git
andmiao
cc_iptables
cc_iptables
master

搜索帮助