: ' : Use nslookup to find out everything about a given subdomain. : Naturally, you can use nslookup manually, but this does it all in 1 step. : : Usage: subinfo [-all] [-a][-d][-h][-m][-s] subdomain : -all queries all authoritatative nameservers : -# skip the first # servers : and the remaining flags are passed to the ls command in nslookup : -d queries for everything (the default) : -a queries only for aliases : -h queries only for hostnames, CPU, and OS : -m queries only for mail preference metrics : -s queries only for services : : Corey Satten, corey@cac.washington.edu 7/3/89 : ' DEFAULT_ROOT="rutgers.edu" DEFAULT_NS=128.6.7.21 # gather up flags which request what kind of 'ls' to do for i in $*; do case "$1" in -all) AFLAG=all; shift;; #query all nameservers -[0-9]*) SKIP=$1; shift;; #skip this many servers -[adhms]) LSFLAGS="$LSFLAGS $1"; shift;; '?') set a b c; break;; #fall into usage message *) break;; esac done LSFLAGS=${LSFLAGS-"-d"} #default action is ls -d (everything) # make sure a subdomain to list has been specified case $# in 1) SUBDOMAIN=$1;; *) echo "Usage: $0 [-all|#] [-a][-d][-h][-m][-s] subdomain" 1>&2; exit 1;; esac # if subdomain has no dots in it, append $DEFAULT_ROOT case $SUBDOMAIN in *.*) break;; *) SUBDOMAIN=$SUBDOMAIN.$DEFAULT_ROOT;; esac # find an appropriate initial nameserver for nslookup case "$SKIP" in "") RCL=1;; # use the same SKIP flag to -1) RCL=2;; # skip entries in /etc/resolv.conf -2) RCL=3;; *) RCL=1;; esac if [ -f /etc/resolv.conf ] ;then DEFAULT_NS=`sed -n 's/^nameserver //p' /etc/resolv.conf | sed -n "$RCL"p` fi # find the appropriate (authoritative) nameservers for ls to query NSL=`echo " set q=ns server $DEFAULT_NS $SUBDOMAIN " | nslookup | sed -n ' /server name =/ { /^.* \([^ ]*\)$/s//\1/p } /nameserver =/ { /^.* \([^ ]*\)$/s//\1/p } '` # then query them one by one with the ls command and selected options set x $NSL; shift # if -# was given, then skip the first # of servers case "$SKIP" in -*) shift `expr $SKIP : '-\(.*\)'`;; esac for NS in $*; do case "$AFLAG" in all) echo "=============== info from $NS ===============";; esac ( echo server $DEFAULT_NS echo server $NS for LSFLAG in $LSFLAGS; do echo ls $LSFLAG $SUBDOMAIN done ) | nslookup case "$AFLAG" in '') break;; esac done