Tuesday, April 21, 2015

Checking DNS internal and external


$ more chk_dns_record.sh
#!/bin/sh
###################################################################################
#  
#  SCRIPT:  Checks Internal and external DNS query.
#  Author:  Sam                                                                                                            
#  Date:    Wed Apr 15 14:42:55 EDT 2015
#  Usage:   Simply run ./dns_chk_in.sh script.
#  Detail:  There is a file dns.chk for external DNS and dns_chk_in for internal.
#           Add some domain on dns.chk and some host from I-Center on dns_chk_in.
#  $ more  dns.chk      
#  abc.com        
#  yahoo.com      
#  $ more dns_chk_in                                                                                                      
#  myserv1
#  myserv2  
#  --------------- Change Log ----------------
#
#        
###################################################################################
#
echo "Checking Mail Relay"
sleep 2
echo "Checking mail delivery from `hostname`" | mailx -s "Checking Mail Relay" sam@mycompany.com
echo
##############################################
echo "Checking external DNS record"
sleep 2
for i in `cat dns.chk`
do
        nslookup $i | tail -3
done
##############################################
echo "Please wait, checking internal DNS query"
sleep 2
echo
echo "Plase wait, checking DNS query"
rm dns_chk_in.rev
for i in `cat dns_chk_in`
do
        nslookup $i-int.expanor.local | tail -3 | tr "\n"   " "
        echo
        nslookup $i-int.expanor.local | tail -2 | grep -v server | awk '{print $2}'>>dns_chk_in.rev
done
###############################################
echo "Now, checking reverse DNS lookup"
echo
echo "Checking Reverse Look up"
for i in `cat dns_chk_in.rev`
do
        nslookup $i| head -4 | tail -1
done

No comments:

Post a Comment