Pages

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 ipad.sh

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

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


# 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


Then make the text file as executable file.

sudo chmod +x ipad.sh

Next execute the script 'ipad.sh'

./ipad.sh



1 comments:

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!