码迷,mamicode.com
首页 > 其他好文 > 详细

自动屏蔽访问异常的ip脚本

时间:2015-09-07 19:36:45      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:屏蔽ip ip黑名单

#!/bin/bash
netstat -an|grep 80 |awk -F[:‘ ‘]+ ‘{print $6}‘  |sort -rn |uniq -c|awk ‘{ if($1>=25)print $2}‘>/tmp/dropip
#netstat -an|grep EST |awk -F[:‘ ‘]+ ‘{print $6}‘  |sort -rn |uniq -c |sort -rn |head -10 |awk ‘{ if($1>15)print $2}‘>/tmp/dropip
for i in $(cat /tmp/dropip|grep -v ‘127.0.0.1‘)
do
/sbin/iptables -I INPUT -p tcp --dport 80 -s $i -j DROP
echo "$i kill at `date`" >>/var/log/gua_ip.txt
done


本文出自 “apache323” 博客,请务必保留此出处http://apache323.blog.51cto.com/6134209/1692451

自动屏蔽访问异常的ip脚本

标签:屏蔽ip ip黑名单

原文地址:http://apache323.blog.51cto.com/6134209/1692451

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!