while true
do
cat /var/log/httpd/access_log | awk ‘{print $1}‘| sort | uniq -c >tmp.txt
cat tmp.txt| while read line
do
pv=echo $line | awk ‘{print $1}‘
ipaddress=echo $line | awk ‘{print $2}‘
if [ "$pv" -gt 100 ]
then
iptables -I INPUT -s ${ipaddress} -j DROP
echo ${ipaddress}
fi
done
sleep 20
done
原文地址:http://blog.51cto.com/11381919/2097030