Checking DNS status of a site
There are situations where you need to quickly check if the DNS records for a particular site
have been updated in the public DNS servers after you make certain changes. The following is a simple script that does just that :
- First create a file named digsite.servers containing a list of public DNS servers against whom you want to check your DNS records.
- Create a script file digsite.sh as follows :
servers=""
checkServer()
{
c1=0
c2=0
set="NOT SET"
SET=0
for ii in `dig @$1 $2 any 2>&1`
do
if test $c2 = 1 ; then
c2=2
fi
if test $c1 = 3 -a "AA$ii" = "AAA" ; then
c2=1
fi
if test $c2 = 2 ; then
set="$ii"
SET=1
break
fi
if test $c1 = 0 -a "AA$ii" = "AA;;" ; then
c1=1
elif test $c1 = 1 ; then
if test "AA$ii" = "AAANSWER" ; then
c1=2
else
c1=0
fi
elif test $c1 = 2 ; then
if test "AA$ii" = "AASECTION:" ; then
c1=3
else
c1=0
fi
fi
done
ss=`echo $1@@@@@@@@@@@@@@@@@@@@@@@@@ | cut -c1-33`
ss=`echo $ss | tr "@" "."`
echo -e " $ss $set"
if test $SET = 0 ; then
servers=`echo $servers $1`
fi
}
if test $# = 0 ; then
echo nsite site_name
exit
fi
site=$1
name=""
NAME=0
for ii in `echo .:$PATH | tr ':' ' '`
do
if test -f $ii/digsite.servers ; then
name=`cat $ii/digsite.servers`
NAME=1
break;
fi
done
if test $NAME = 0 ; then exit ; fi
clear
cnt=0
for ii in $name
do
if test $cnt = 0 ; then
echo -e " Checking $site on:"
fi
cnt=`expr $cnt + 1`
checkServer $ii $site
if test $cnt = 23 ; then
cnt=0
fi
done
if test "AA$servers" != "AA" ; then
echo -e "\n $site NOT SET on: "
for ii in $servers
do
echo " $ii"
done
fi




