Shell Script – Domain Whois

#!/bin/bash
# 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

Dependinte:

whois

Instalare whois Debian/Ubuntu:

apt-get install whois

Scriptul trebuie sa fie executabil:

chmod +x script.sh

Cum folosim scriptul?

./script.sh yahoo.com google.com

Output:

Getting information for domain: yahoo.com [ 67.195.160.76 ]...
OrgName: Yahoo! Inc.
City: Sunnyvale
Country: US
NetRange: 67.195.0.0 - 67.195.255.255

Getting information for domain: google.com [ 74.125.77.147 ]...
OrgName: Google Inc.
City: Mountain View
Country: US
NetRange: 74.125.0.0 - 74.125.255.255

3 thoughts on “Shell Script – Domain Whois”

Leave a Reply

Your email address will not be published. Required fields are marked *