#!/bin/sh
[ -f tmp.txt ] && rm -fr tmp.txt
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