small vent
Greg A. Woods
woods at most.weird.com
Sat Jun 27 18:12:48 UTC 1998
[ On Sat, June 27, 1998 at 10:11:54 (-0700), Michael Dillon wrote: ]
> Subject: Re: small vent
>
> Why can't the ISPs get their act together and use a whois client that
> allows a simple request like "whois name" to find the appropriate
> database? This is simple enough that it could be done with a PERL script
> frontend to the regular whois client and as an added bonus it could lookup
> info in the country-code TLD databases as well.
Perl shmerl (though as you'll see below shell scripts still don't have
very good facilities for dealing with inet numbers):
(this isn't internationalized, yet; apologies to non-English speakers)
---------- cut here ----------
#! /bin/sh
:
#
# awhois - all-encompassing whois client wrapper....
#
# (c) Copyright 1998 Greg A. Woods.
# Freely redistibutable.
# All other rights reserved.
# Return all fixes/modifications to <woods at planix.com>.
#
#ident "@(#)LOCAL:awhois.sh 1.8 98/05/02 22:07:14 (woods)"
#ident "@(#)awhois:$Name$:$Id$"
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`
QUERY="$*"
if [ -n "$WHOISHOST" ] ; then
exec whois -h $WHOISHOST "$QUERY"
fi
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, AS numbers, ARIN handle patterns, ...
[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|*-ARIN|net-*|NET-*|netblk-*|NETBLK-*|asn-*|ASN-*)
exec whois -h whois.arin.net "$QUERY"
;;
*.com|*.org|*.edu|*.net|*-DOM|*-dom|*-ORG|*-org)
exec whois -h whois.internic.net "$QUERY"
;;
*.mil)
exec whois -h nic.ddn.mil "$QUERY"
;;
*.at)
exec whois -h whois.univie.ac.at "$QUERY"
;;
*.au)
exec whois -h whois.aunic.net "$QUERY"
;;
*.ca)
exec whois -h whois.cdnnet.ca "$QUERY"
;;
*.ch)
exec whois -h whois.nic.ch "$QUERY"
;;
*.de)
exec whois -h whois.nic.de "$QUERY"
;;
*.fr)
exec whois -h whois.nic.fr "$QUERY"
;;
*.it)
exec whois -h whois.nis.garr.it "$QUERY"
;;
*.kr)
exec whois -h whois.krnic.net "$QUERY"
;;
*.jp)
exec whois -h whois.nic.ad.jp "$QUERY/e"
;;
*.mx)
exec whois -h nic.mx "$QUERY"
;;
*.nl)
exec whois -h www.domain-registry.nl "$QUERY"
;;
*.pk)
exec whois -h whois.pknic.net.pk "$QUERY"
;;
*.se)
exec whois -h whois.sunet.se "$QUERY"
;;
*.sg)
exec whois -h whois.nic.net.sg "$QUERY"
;;
*.th)
exec whois -h whois.thnic.net "$QUERY"
;;
*.com.tw)
exec whois -h whois.iii.org.tw "$QUERY"
;;
*.tw)
exec whois -h whois.twnic.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"
;;
[a-zA-Z][a-zA-Z][0-9]*|[a-zA-Z][a-zA-Z][a-zA-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
exec whois -h $DEFAULTWHOISHOST "$QUERY"
---------- end here ----------
--
Greg A. Woods
+1 416 443-1734 VE3TCP <gwoods at acm.org> <robohack!woods>
Planix, Inc. <woods at planix.com>; Secrets of the Weird <woods at weird.com>
More information about the NANOG
mailing list