#! /bin/sh : # # awhois - all-encompassing whois client wrapper.... # # (c) Copyright 1998 Greg A. Woods. # (c) Copyright 1999 Greg A. Woods. # Freely redistibutable. # All other rights reserved. # Return all fixes/modifications to . # #ident "@(#)LOCAL:awhois.sh 1.27 99/04/26 16:02:21 (woods)" #ident "@(#)awhois:$Name$:$Id$" # NOTE: There are some guys at www.geektools.com who are trying to do # something similar to this via a WWW interface. They've also set up # a domain 'whois-servers.net' which contains TXT and CNAME records # pointing at what should be the whois server for a given TLD. They # don't yet have as many domains covered as I do, but they're likely # to be more up-to-date than this script is! For now the hard-coded # server names will take precedence, but at some point I may split the # lookup into several sections and prefer the pointer in # whois-servers.net to the hard-coded names. # XXX # this script should really just be a part of the rwhois client's # XXX # scheme for falling back to traditional WHOIS queries. argv0=`basename $0` DEFAULTWHOISHOST="whois.internic.net" USAGE="Usage: $argv0 [-h whois-host] query-string" HELP="$USAGE -h host query the specified host. The appropriate whois server will be chosen based on the query-string given, so long as it is recognized as a handle, host, domain, network, AS number, etc. If the query-string doesn't match an appropriate pattern the default server ($DEFAULTWHOISHOST) will be queried. " WHOISHOST="" while getopts "h:H" OPTCHAR ; do case $OPTCHAR in h) WHOISHOST=$OPTARG ;; H) echo "$HELP" 1>&2 exit 2 ;; \?) echo "$USAGE" 1>&2 exit 2 ;; esac done shift `expr $OPTIND - 1` # so far as I know all whois servers are case-insensitive.... # XXX this invocation of tr should work for SysV & BSD & POSIX # QUERY=`echo "$*" | tr '[A-Z]' '[a-z]'` QUERYTLD=`echo $QUERY | sed 's/^.*\.\([^\.]*\)$/\1/'` if [ "X${QUERY}" = "X" ] ; then echo "$USAGE" 1>&2 exit 2 fi if [ -n "$WHOISHOST" ] ; then exec whois -h $WHOISHOST "$QUERY" fi # XXX there's lots of info about how to use the RIPE database # XXX more effectively at: # XXX http://www.ripe.net/docs/ripe-157.html#toc18 case "$QUERY" in # mostly derived from "whois -h whois.arin.net European" 62.*|163.12[89].*|163.1[3][0-9].*|163.14[0-3].*|164.40.*|171.1[6-9].*|171.2[0-9].*|171.3[0-3].*|192.162.*|192.16[4-7].*|19[3-5].*) exec whois -h whois.ripe.net "$QUERY" ;; # mostly derived from "whois -h whois.arin.net Asia" 61.*|169.20[89].*|169.21[0-9].*|169.22[0-3].*|20[23].*|21[01].*) exec whois -h whois.apnic.net "$QUERY" ;; # This is a bit of a quick&dirty hack. # ARIN's info for this (under NETBLK-SEED-NETS) says: 192.72.3.0 - 192.72.252.0 192.72.*) exec whois -h whois.iii.org.tw "$QUERY" ;; # the rest of the IP numbers, ARIN handle patterns, ... # (net handles, netblk handles, and AS numbers, come at the end) [1-9].*|[1-9][0-9].*|[12][0-9][0-9].*|[0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9]|*-arin) exec whois -h whois.arin.net "$QUERY" ;; *.com|*.org|*.edu|*.net|*-dom|*-org) exec whois -h whois.internic.net "$QUERY" ;; *.gov) exec whois -h whois.nic.gov "$QUERY" ;; *.int) exec whois -h whois.isi.edu "$QUERY" ;; *.mil) exec whois -h whois.nic.mil "$QUERY" ;; *.ac) exec whois -h whois.nic.ac "$QUERY" ;; *.al) exec whois -h whois.ripe.net "$QUERY" ;; *.am) exec whois -h whois.amnic.net "$QUERY" ;; *.as) exec whois -h whois.nic.as "$QUERY" ;; *.at) exec whois -h whois.univie.ac.at "$QUERY" ;; *.net.au) exec whois -h whois.connect.com.au "$QUERY" ;; *.au) exec whois -h whois.aunic.net "$QUERY" ;; *.az) exec whois -h whois.ripe.net "$QUERY" ;; *.ba) exec whois -h whois.ripe.net "$QUERY" ;; *.be) exec whois -h whois.ripe.net "$QUERY" ;; *.bg) exec whois -h whois.ripe.net "$QUERY" ;; *.by) exec whois -h whois.ripe.net "$QUERY" ;; *.ca) exec whois -h whois.cdnnet.ca "$QUERY" ;; *.ch) exec whois -h whois.nic.ch "$QUERY" ;; *.ac.cn) exec whois -h whois.cnc.ac.cn "$QUERY" ;; *.cn) exec whois -h whois.cnnic.net.cn "$QUERY" ;; *.cy) exec whois -h whois.ripe.net "$QUERY" ;; *.cz) exec whois -h whois.ripe.net "$QUERY" ;; *.de) exec whois -h whois.nic.de "$QUERY" ;; *.dk) exec whois -h whois.ripe.net "$QUERY" ;; *.dz) exec whois -h whois.ripe.net "$QUERY" ;; *.ee) exec whois -h whois.ripe.net "$QUERY" ;; *.eg) exec whois -h whois.ripe.net "$QUERY" ;; *.es) exec whois -h whois.ripe.net "$QUERY" ;; *.fi) exec whois -h whois.ripe.net "$QUERY" ;; *.fo) exec whois -h whois.ripe.net "$QUERY" ;; *.fr) exec whois -h whois.nic.fr "$QUERY" ;; *.gb) exec whois -h whois.ripe.net "$QUERY" ;; *.ge) exec whois -h whois.ripe.net "$QUERY" ;; #*.gr) # exec whois -h whois.forthnet.gr "$QUERY" # ;; *.gr) exec whois -h whois.ripe.net "$QUERY" ;; *.hk) exec whois -h whois.apnic.net "$QUERY" ;; *.hr) exec whois -h whois.ripe.net "$QUERY" ;; *.hu) exec whois -h whois.ripe.net "$QUERY" ;; *.ie) exec whois -h whois.ripe.net "$QUERY" ;; *.il) exec whois -h whois.ripe.net "$QUERY" ;; *.is) exec whois -h whois.ripe.net "$QUERY" ;; *.it) exec whois -h whois.nic.it "$QUERY" ;; *.jp|[a-z][a-z][0-9][0-9][0-9]jp) exec whois -h whois.nic.ad.jp "$QUERY/e" ;; *.kr) exec whois -h whois.krnic.net "$QUERY" ;; *.li) exec whois -h whois.nic.li "$QUERY" ;; *.lk) exec whois -h whois.nic.lk "$QUERY" ;; *.lt) exec whois -h whois.ripe.net "$QUERY" ;; *.lu) exec whois -h whois.ripe.net "$QUERY" ;; *.lv) exec whois -h whois.ripe.net "$QUERY" ;; *.ma) exec whois -h whois.ripe.net "$QUERY" ;; *.md) exec whois -h whois.ripe.net "$QUERY" ;; *.mk) exec whois -h whois.ripe.net "$QUERY" ;; *.mm) exec whois -h whois.nic.mm "$QUERY" ;; *.mt) exec whois -h whois.ripe.net "$QUERY" ;; *.mx) exec whois -h nic.mx "$QUERY" ;; *.nl) exec whois -h www.domain-registry.nl "$QUERY" ;; *.no) exec whois -h whois.ripe.net "$QUERY" ;; *.nz) exec whois -h tardis.patho.gen.nz "$QUERY" ;; *.pl) exec whois -h whois.ripe.net "$QUERY" ;; *.pk) exec whois -h whois.pknic.net.pk "$QUERY" ;; *.pt) exec whois -h whois.dns.pt "$QUERY" ;; *.ro) exec whois -h whois.ripe.net "$QUERY" ;; *.ru) exec whois -h whois.ripn.net "$QUERY" ;; *.se) exec whois -h whois.nic-se.se "$QUERY" ;; *.si) exec whois -h whois.ripe.net "$QUERY" ;; *.sg) exec whois -h whois.nic.net.sg "$QUERY" ;; *.sh) exec whois -h whois.nic.sh "$QUERY" ;; *.sk) exec whois -h whois.ripe.net "$QUERY" ;; *.sm) exec whois -h whois.ripe.net "$QUERY" ;; *.su) exec whois -h whois.ripe.net "$QUERY" ;; *.th) exec whois -h whois.thnic.net "$QUERY" ;; *.tj) exec whois -h whois.nic.tj "$QUERY" ;; *.tn) exec whois -h whois.ripe.net "$QUERY" ;; *.tr) exec whois -h whois.ripe.net "$QUERY" ;; *.com.tw) exec whois -h whois.iii.org.tw "$QUERY" ;; *.tw) exec whois -h whois.twnic.net "$QUERY" ;; *.ua) exec whois -h whois.ripe.net "$QUERY" ;; *.ac.uk) exec whois -h whois.ja.net "$QUERY" ;; *.co.uk|*.org.uk|*.net.uk|*.plc.uk|*.gov.uk|*.net.uk) exec whois -h whois.nic.uk "$QUERY" ;; *.uk) exec whois -h whois.nic.uk "$QUERY" ;; *.us) exec whois -h whois.isi.edu "$QUERY" ;; *.va) exec whois -h whois.ripe.net "$QUERY" ;; *.yu) exec whois -h whois.ripe.net "$QUERY" ;; # must come last to avoid kacking net-foo.com, etc.... net-*|netblk-*|asn-*) exec whois -h whois.arin.net "$QUERY" ;; # catch-all.... [a-z][a-z][0-9]*|[a-z][a-z][a-z][0-9]*) exec whois -h whois.internic.net "$QUERY" ;; esac echo "Warning: '$argv0' knows not which whois server to talk to for '$QUERY'." 1>&2 echo "Trying look-up via WHOIS server listed at '${QUERYTLD}.whois-servers.net'...." 1>&2 exec whois -h ${QUERYTLD}.whois-server.net "$QUERY" .