Script to check the Forward/Reverse DNS entries are sane for host

#! /bin/bash</p>

name=`hostname -f`

ip=$(ifconfig eth0 | grep "inet addr" | awk -F '[: ]' '{print $13}')

forward=$(host $name | awk -F " address " '{print $2}')

reverse=$(host $ip | awk -F "pointer " '{print $2}' | sed 's/\.$//g')

if [ "$ip" = "$forward" ]; then

echo -e "Forward Lookup is ok"

else

echo -e "\nForward lookup does not match with assigned IP address.IP address is $ip while DNS ponits to $forward."

fi

if [ "$name" = "$reverse" ]; then

echo -e "\nReverse Lookup is ok"

else

echo -e "\nReverse lookup does not match with hostname.Hostname is $name while Reverse DNS ponits to $reverse."

fi

comments powered by Disqus