Home   >>   Scripts   >>   Shell Script To Get Data Center Information, IP Owner, City and Country From Domain Name
Shell Script To Get Data Center Information, IP Owner, City and Country From Domain Name PDF Print E-mail
( 1 Vote )
How To - Scripts
Written by Christian Foronda   
Monday, 27 September 2010 18:58
# vi get-whois

 

#!/bin/bash
# A sample shell script to print domain ip address hosting information such as
# Location of server, city, ip address owner, country and network range.
# This is useful to track spammers or research purpose.
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project 
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Last updated on Mar/05/2010
# -------------------------------------------------------------------------
	 
# Get all domains
_dom=$@
 
# Die if no domains are given
[ $# -eq 0 ] && { echo "Usage: $0 domain1.com domain2.com ..."; exit 1; }
for d in $_dom
do
	_ip=$(host $d | grep 'has add' | head -1 | awk '{ print $4}')
	[ "$_ip" == "" ] && { echo "Error: $d is not valid domain or dns error."; continue; }
	echo "Getting information for domain: $d [ $_ip ]..."
	whois "$_ip" | egrep -w 'OrgName:|City:|Country:|OriginAS:|NetRange:'
	echo ""
done

 

# chmod +x get-whois

 

Usage:

# get-whois google.com
	
Getting information for domain: google.com [ 74.125.53.99 ]...
NetRange:       74.125.0.0 - 74.125.255.255
OriginAS:       
OrgName:        Google Inc.
City:           Mountain View
Country:        US

 

Reference:
http://bash.cyberciti.biz




blog comments powered by Disqus
Last Updated on Wednesday, 16 February 2011 11:49