Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

Follow by Email

reverse dns lookup script

I'm share to check reverse dns lookup in bash script. You can check online reverse dns lookup with https://mxtoolbox.com/ or http://www.dnsqueries.com/en/reverse_lookup.php and so on.

reverse dns lookup script

reverse dns lookup script


#!/bin/bash
#MTA Reverse DNS lookup:
#For MTA
# dig domain.com +short @8.8.8.8
# dig -x 111.222.121.221 +short @8.8.8.8
rm -f /tmp/reverse_lookup_MTA
IP1="111.222.121.221"
MTA="domain.com"
DIG1=$(dig $MTA +short @8.8.8.8)
PTR1=$(dig -x $DIG1 +short @8.8.8.8 | sed 's/.$//')

#To check MTA DNS lookup status
echo "##### MTA Reverse DNS lookup and PTR Query #####" >/tmp/reverse_lookup_MTA
if [ "$MTA" != "$PTR1" ]; then
echo "$MTA != $PTR1" >>/tmp/reverse_lookup_MTA
echo "Reverse lookup Failed!" >>/tmp/reverse_lookup_MTA
elif [ "$IP1" != "$DIG1" ]; then
echo "$IP1 != $DIG1" >>/tmp/reverse_lookup_MTA
echo "Lookup the IP address Failed!" >>/tmp/reverse_lookup_MTA

else
echo "$DIG1 = $MTA" >>/tmp/reverse_lookup_MTA
echo "Sucess!" >>/tmp/reverse_lookup_MTA

fi
echo ""

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com