Get Whois Info On All Your Accounts

If you have a program or script that you'd like to give away or sell, this is the place to do it. All offers should include contact info.

Moderators: BBear, theunknownhost, flaguy

Post Reply
User avatar
Arf
Official Test Penquin
Posts: 9103
Joined: Tue Apr 09, 2002 12:00 am
Location: IDAHO, USA
Contact:

Get Whois Info On All Your Accounts

Post by Arf » 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....



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.

User avatar
datazen
Hosting Superstar
Posts: 1084
Joined: Thu Feb 19, 2004 10:20 pm
Location: Jacksonville, FL

Post by datazen » Wed Oct 05, 2005 3:44 pm

BEAUTIFUL!! Or as W. Shatner would say ... BRILLIANT!!

Arf, you always seem to know what I'm thinking Thanks for the script. It's more useful than you even know. :wink:

User avatar
Arf
Official Test Penquin
Posts: 9103
Joined: Tue Apr 09, 2002 12:00 am
Location: IDAHO, USA
Contact:

Post by Arf » Wed Oct 05, 2005 6:01 pm

Excellent. I'm really glad it could be of help. (I'm just guessing but I'll be this has something to do with your EV1 server possibly?)

(Personal note: We really missed you at AlaCon2005. So we just sat around and talked behind your back... oh and we cried a lot. )

User avatar
Arf
Official Test Penquin
Posts: 9103
Joined: Tue Apr 09, 2002 12:00 am
Location: IDAHO, USA
Contact:

Post by Arf » Thu Oct 13, 2005 9:42 pm

I have to take back my remarks about the whois command. The good news is that Alabanza took one of my comments and may be rolling it out to all of the servers. Note below:

Thomas,

Last week, I passed along your request to Tim ****** in our SysAdmin
group. His staff liked your suggestion and worked on a jwhois rollout.
They expect to pass it to QA this week.

Thanks,
~~~~~



So, some time in the next few months we might see this on our servers. Yea! Thank you Alabanza!

User avatar
theunknownhost
Official Test Penquin
Posts: 2713
Joined: Mon Aug 05, 2002 1:05 pm

Post by theunknownhost » Thu Oct 13, 2005 9:47 pm

That would be nice! At least 3-4 times a day I have to login to a non-ala server to run a real whois and then close it out and go back to the ala server.

User avatar
theunknownhost
Official Test Penquin
Posts: 2713
Joined: Mon Aug 05, 2002 1:05 pm

Post by theunknownhost » Wed Nov 16, 2005 8:15 pm

Awesome script! We're in the process of completing an acquisition. They provided us with a list of domains that are hosted. I then dumped them in a text file with 0.0.0.0 domain.com as the format. Then I set the search string to their dns. Pretty sweet - a fast an easy way to find out how many of those domains are actually hosted!

User avatar
Arf
Official Test Penquin
Posts: 9103
Joined: Tue Apr 09, 2002 12:00 am
Location: IDAHO, USA
Contact:

Post by Arf » Wed Nov 16, 2005 10:53 pm

theunknownhost wrote:Awesome script! We're in the process of completing an acquisition. They provided us with a list of domains that are hosted. I then dumped them in a text file with 0.0.0.0 domain.com as the format. Then I set the search string to their dns. Pretty sweet - a fast an easy way to find out how many of those domains are actually hosted!


I'm really glad you found it useful. I hope I can hit some more home runs in the future.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest