Thursday, May 13, 2010

Ubuntu: How to get ip address,owener of domain name,etc

The following steps to know the ip address,owener of the domain name,etc .

1. Type the following command in terminal and open the empty text file

sudo gedit

Copy and paste the following lines in the text file then save and exit

# 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.
# -------------------------------------------------------------------------

# Get all domains

# Die if no domains are given
[ $# -eq 0 ] && { echo "Usage: $0 ..."; exit 1; }
for d in $_dom
_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 ""

Then make the text file as executable file.

sudo chmod +x

Next execute the script ''



Anonymous said...

Dude! This is the coolest script in the world. Thank you for this. Shell scripting is such a great thing. Now I don't have to tinker with my firewall just to find the IP of a domain name!