#Date:     Mon, 26 Apr 93 9:13:55 MET DST
#From: Hans van Staveren <sater@cs.vu.nl>
#To: bind@ucbarpa.berkeley.edu
#Subject:  Re:  send me your tools
#Message-Id:  <9304260913.aa18851@sater.cs.vu.nl>
#
#We daily call the following script to check forward/reverse mapping
#consistency:
#
#/usr/share/local/script/checkDNS\
#        cs.vu.nl am.cs.vu.nl 192.31.231\
#        130.37.16 130.37.18 130.37.20 130.37.22\
#        130.37.24 130.37.26 130.37.28 130.37.30>/tmp/chk.$$
#
#No documentation I am afraid. Just run it and see what is reported.
#
#	Hans
#
: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting checkDNS'
sed 's/^X//' > checkDNS << '+ END-OF-FILE checkDNS'
X#!/bin/sh
X# Script to check forward/reverse name mapping consistency
X# Author: Hans van Staveren <sater@cs.vu.nl>
X#
XPATH=/usr/local/bin:/usr/ucb:/usr/bin
Xcase $# in
X0) echo "Usage: $0 [-p] [domain or network] ...";exit;
Xesac
Xping=no
Xcase $1 in
X-p*)	ping=yes;shift;;
Xesac
Xfor domain
Xdo
X    case $domain in
X    *[A-Za-z]*)
X	host -l $domain|sort -u|grep 'has address'|
X		grep -v -e '-net[0-9]'|grep -v localhost|
X	while read hostname has address ipaddr
X	do
X		revname=`host $ipaddr 2>/dev/null|sed -n 's/^Name: //p'`
X		if [ -z "$revname" ]
X		then revname="black-hole"
X		fi
X		hostname=`echo $hostname|tr '[A-Z]' '[a-z]'`
X		revname=`echo $revname|tr '[A-Z]' '[a-z]'`
X		if [ $hostname != $revname -a $revname != localhost ]
X		then echo "$hostname -> $ipaddr -> $revname"
X		fi
X		case $ping in
X		yes)
X			if /usr/etc/ping $hostname 5 >/dev/null 2>&1
X			then : nothing
X			else
X				echo $hostname does not respond
X			fi
X			;;
X		esac
X	done
X	;;
X    *)
X	# Only class C style networks work currently
X	netdom=`echo $domain|sed 's/\(.*\)\.\(.*\)\.\(.*\)/\3.\2.\1/'`.in-addr.arpa
X	host -l $netdom|sort -u|grep '^[^0].* PTR '|
X	while read enc_ipaddr PTR hostname
X	do
X		ipaddr=`echo $enc_ipaddr|sed 's/\(.*\)\.\(.*\)\.\(.*\)\.\(.*\)\.IN.*/\4.\3.\2.\1/'`
X		if host $hostname 2>/dev/null|grep -s "has address $ipaddr"
X		then
X			: hunky dory
X		else
X			echo "$ipaddr -> $hostname, but no A record"
X		fi
X		case $ping in
X		yes)
X			if /usr/etc/ping $hostname 5 >/dev/null 2>&1
X			then : nothing
X			else
X				echo $hostname does not respond
X			fi
X			;;
X		esac
X	done
X	;;
X    esac
Xdone
+ END-OF-FILE checkDNS
chmod 'u=rwx,g=rx,o=rx' 'checkDNS'
echo 'SENT: -rwxr-xr-x  1 sater        1554 Mar 19  1992 checkDNS'
echo -n 'RCVD: '
/bin/ls -l checkDNS
exit 0
