Activities

October 2014
M T W T F S S
« Sep   Nov »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Finding external hosted domains those are not using my nameservers

One of my client has given a list of 364 domains those he managed for customer accounts. He does not know what all those are active and hosted on the aged Whm/Cpanel server he is using currently. It is very hard for me to found the domain name which are using his current name server by looking WHOIS record for all 364 domains.

So I plan to prepare a bash script to use “whois” command to find those details and output will written to a file. So that I can worry about those domain during the site migration time.

Script for finding the domain names those are using our name servers from a domain list.

you can download it from here

#!/bin/bash
# path of the files which you stored all the domains names
domain_list_file="/root/OR_Domain_names.txt"
#path of the output files those are using your name servers
ext_domain_file="/root/exterenal_domains.txt"
touch $ext_domain_file
#Type your name server names
nameserver_check="NS1.MYDOMAIN.COM"
cat /dev/null > $ext_domain_file
counter=0
ext_count=0
while read line
do
clear
echo "Domain processed :: $counter, Active Domain:: $line , External Domains :: $ext_count "
name_server_name="$(whois $line | grep "Name Server" | awk '{print $3}'|head  -n 1)"

if [ "$name_server_name"  == "$nameserver_check"   ]
then
  echo " "
else
ext_count=$((ext_count+1))
#unset name_registrar_name
name_registrar_name="$(whois $line  | grep "Registrar" | awk '{print $2 $3}'|head  -n 1)"

echo "$line"  $name_registrar_name  >> $ext_domain_file
fi

counter=$((counter+1))
 
done <"$domain_list_file"

echo " ##### Done ####

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>