#!/bin/sh # sh. not fucking bash. if [ ! $# -gt 0 ]; then echo "Usage: $0 [filterdomain]" exit 1; fi tld=$1 shift digopts='+norecurse +nocmd +nocomments +nostats +noadditional +noquestion' domfilter=0 # handle the filterdomain if [ $# -gt 0 ]; then domfilter=1 filter_domain=$1 echo "using domfilter: '$filter_domain'" fi get_tldns() { tld=`echo $1 | sed 's/^.*\.//'` host -t ns $tld. | head -1 | awk '{print $4}' } echo > $tld.ns for i in `cat $tld`; do echo "Checking $i..." if [ $domfilter -eq 1 ]; then dig @`get_tldns $i` $i NS $digopts | grep NS | grep -iv $filter_domain'\.$' >> $tld.ns else dig @`get_tldns $i` $i NS $digopts | grep NS >> $tld.ns fi done