Get Whois Info On All Your Accounts
Posted: Wed Oct 05, 2005 9:18 am
I have to find out what name servers my clients are pointing their domain names to. Specifically, I'm searching for names that point to a reseller's name servers so I can notify them that the name servers are changing. If you're ever in the same boat, this program will help find positive matches for domains that are pointing to the name servers in question.
I'll pre-empt this with the bad news. Unlike the one on Ala's servers, this script expects a functional whois that can handle a wide variety of TLDs. I recommend you install:
jwhois version 3.2.2+, Copyright (C) 1999-2003 Free Software Foundation, Inc. or you can run it on a server such as those at EV1 that have this as a standard program.
Moving on....
The results look something like this:
Hope this helps somebody as much as it has me.
I'll pre-empt this with the bad news. Unlike the one on Ala's servers, this script expects a functional whois that can handle a wide variety of TLDs. I recommend you install:
jwhois version 3.2.2+, Copyright (C) 1999-2003 Free Software Foundation, Inc. or you can run it on a server such as those at EV1 that have this as a standard program.
Moving on....
Code: Select all
#!/bin/bash
# this program checks domain registrations for a specific string such as a name server so you
# will know who in your /etc/hosts file is using a specific name server.
INPUTFILE="./hosts" #copy of the /etc/hosts file on server in question
SEARCHSTRING="ns.mynameserver.com" #search whois info for this string
OUTPUTWHOIS="registration.txt" #whois info for positive matches
OUTPUTNAMES="domains.txt" #list of domains that have positive matches.
if [ ! -f ./$OUTPUTNAMES ]; then
touch $OUTPUTNAMES
fi
while read EACH; do
DOMAIN=`echo $EACH | awk '{print $2}' | sed 's/#//g'`
#no blank domains
if [ "$DOMAIN" != "" ]; then
if [ `grep -c $DOMAIN $OUTPUTNAMES` -lt 1 ]; then
DOMAIN=`echo $DOMAIN | sed 's/#//g'`
if [ `whois $DOMAIN | grep -ic $SEARCHSTRING` -gt 0 ]; then
echo " [Positive match for $SEARCHSTRING]: $DOMAIN "
echo "$DOMAIN" >> $OUTPUTNAMES
echo -e "\n=====================================\n" >> $OUTPUTWHOIS
whois $DOMAIN >> $OUTPUTWHOIS
else
echo "$DOMAIN"
fi
fi
fi
done < $INPUTFILE
The results look something like this:
Code: Select all
somedomain.com
someotherdomain.com
[Positive match for ns.mynameserver.com]: domainname.com
moredomain.com
blablabla.com
etc.com
Hope this helps somebody as much as it has me.