Jun
13
Posted on 13-06-2007
Filed Under (Shell scripting) by Arun Bagul

Introduction –

This shell script can be used to known whether the IP address of your mail server is black list or not…

Who can use this script ?

– System Admin, Mail Server admin or any one who want to find the IP address is black listed or not?

root@arunbagul:/home/arun/bash-prog# cat black_white_listing.sh
#!/bin/bash
echo “=========================================”
echo “Welcome to IndianGNU.org’s script to check the Blacklisting”

if [ $# -eq 0 ]; then
echo -n “Enter the IP Address of Mail Server: ”
#read the IP from cmd line
read IPAddr
else
IPAddr=$1
fi

#Reverse the IP…
ipaddr1=$(echo $IPAddr | awk -F. ‘{print $1}’)
ipaddr2=$(echo $IPAddr | awk -F. ‘{print $2}’)
ipaddr3=$(echo $IPAddr | awk -F. ‘{print $3}’)
ipaddr4=$(echo $IPAddr | awk -F. ‘{print $4}’)

##check the IP format here…

if [ “$ipaddr1” == “” ]; then
echo “Please enter the Valid IP address”
exit
elif [ “$ipaddr2” == “” ]; then
echo “Please enter the Valid IP address”
exit
elif [ “$ipaddr3” == “” ]; then
echo “Please enter the Valid IP address”
exit
elif [ “$ipaddr4” == “” ]; then
echo “Please enter the Valid IP address”
exit
fi

### create reverse IP
RevIP=”${ipaddr4}.${ipaddr3}.${ipaddr2}.${ipaddr1}”

echo “The IP (Reverse format):- ${RevIP}”

###################################
for check in {blocked.hilli.dk blacklist.sci.kun.nl,spamsources.dnsbl.info,map.spam-rbl.com \
mail-abuse.blacklist.jippg.org catchspam.com spam.blackhole.cantv.net blackholes.uceb.org dnsbl.solid.net}
do
#run cmd to check the IP black listed or not
dig ${RevIP}.$check >> /dev/null
if [ $? = 0 ]; then
echo “The ${IPAddr} IS White Listed”
else
echo “The ${IPAddr} IS Black Listed”
fi
done
#done
root@arunbagul:/home/arun/bash-prog#

How to use this script ?

root@arunbagul:/home/arun/bash-prog# ./black_white_listing.sh
=========================================
Welcome to IndianGNU.org’s script to check the Blacklisting
Enter the IP Address: 192.168.0.1
The IP (Reverse format):- 1.0.168.192
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
The 192.168.0.1 IS White Listed
root@arunbagul:/home/arun/bash-prog#

Thank you,

Arun Bagul

Similar Posts:

Be Sociable, Share!
(2) Comments    Read More   

Comments

Windows VPS on 14 August, 2012 at 12:06 pm #

How can I check multiple IPs at a time without entering manually?

I have created a php script using Net_DNSBL module but it not work with multiple ips.

kuch solution bataon na bhai 🙁


sathryan on 3 March, 2016 at 1:58 pm #

Hi,

I have tired this, but it is showing error.
————
sat.sh: 2: sat.sh: “=========================================”: not found
“Welcome to IndianGNU.org’s script to check the Blacklisting”
“Enter the IP Address of Mail Server: ”31.3.155.94
awk: 1: unexpected character 0xe2
awk: line 2: missing } near end of file
awk: 1: unexpected character 0xe2
awk: line 2: missing } near end of file
awk: 1: unexpected character 0xe2
awk: line 2: missing } near end of file
awk: 1: unexpected character 0xe2
awk: line 2: missing } near end of file
sat.sh: 21: [: unexpected operator
sat.sh: 24: [: unexpected operator
sat.sh: 27: [: unexpected operator
sat.sh: 30: [: unexpected operator
sat.sh: 38: sat.sh: Syntax error: “(” unexpected
root@techs-OEM:~#
—————

Plesae let me know the how do i correct it.


Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->