社区站点防灌水脚本
while :;
do
tail -n 50000 /home/logs/access.log |grep '"/post'|awk '{print $1}' |sort |uniq -c |sort -n >/tmp/post1.txt
awk '$1>80 {print $2}' /tmp/post1.txt >/tmp/post2.txt
iptables -nvL |grep REJECT |awk '$1<5 {print $8}' >/tmp/post3.txt
for ip in `cat /tmp/post3.txt`; do
iptables -D INPUT -s $ip -j REJECT
done
for ip in `cat /tmp/post2.txt` ; do
iptables -I INPUT -s $ip -j REJECT
done
sleep 1200
done
do
tail -n 50000 /home/logs/access.log |grep '"/post'|awk '{print $1}' |sort |uniq -c |sort -n >/tmp/post1.txt
awk '$1>80 {print $2}' /tmp/post1.txt >/tmp/post2.txt
iptables -nvL |grep REJECT |awk '$1<5 {print $8}' >/tmp/post3.txt
for ip in `cat /tmp/post3.txt`; do
iptables -D INPUT -s $ip -j REJECT
done
for ip in `cat /tmp/post2.txt` ; do
iptables -I INPUT -s $ip -j REJECT
done
sleep 1200
done
none