Script to check if Googlebot IP is blocked on apf

#!/bin/bash

hostname=`/bin/hostname`
MAIL_BODY=/tmp/googleblock.txt

#Give the email address(es) to which the script will have to send the alerts
MAIL_TO=some_addr@some_domain.com

send_mail()
{
cat $MAIL_BODY|mail -s ” Googlebot IP blocked on $hostname” $MAIL_TO
rm -f $MAIL_BODY
}

for i in `cat /etc/apf/deny_hosts.rules | grep -v “#” `
do
host $i | grep googlebot
if [ $? -eq 0 ]
then
echo $i >> $MAIL_BODY
fi
done

if [ -f $MAIL_BODY ]
then
echo “Check the reverse DNS as well before unblocking this IP” >> $MAIL_BODY
send_mail
fi

Advertisements

One Response to “Script to check if Googlebot IP is blocked on apf”

  1. Steve Says:

    How does an IP end up in deny_hosts.rules?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: