What happened to whois?

Barry Margolin barmar at bbnplanet.com
Tue Feb 15 21:10:19 UTC 2000


In article <88c668$p8m$1 at nnrp1.deja.com>,
post_to_group  <already_seen at my-deja.com> wrote:
>does your script also figure out for government domains? I am trying
>to find whois info on a .gov domain and am not sure how to find the
>whois server(s) for those domains.  A simple whois fails saying it
>only has the com/net/org/edu domains.  And search faq's etc for network
>solutions, arin, DoD, etc. doesn't give me any ref.  I am sorry if it
>is right under my nose, but I am missing the whois servers for .gov.

I use whois.nic.gov for government domains.  If you query
whois.networksolutions.com for !GOV-DOM, it will tell you:

   whois: whois.nic.gov
   web:   www.nic.gov
   email: registrar at nic.gov

Anyway, here's my script.  It references a file "whohosts.txt"; I think I
downloaded this from Richard Sexton's FTP site a while ago (although I
don't care to read all his political posts, I am very thankful to him for
this list), and he occasionally posts a pointer to it.

#!/usr/local/bin/perl

require "getopts.pl";
require "sys/socket.ph";

$port = 43;

&Getopts('h:ars:');

if ($#ARGV < 0) {
	print "Usage: whois [-a] [-h host] [-s source] [-r] key\n";
	exit(0);
}

$whohosts = "/home/sa/barmar/lib/whohosts.txt";
$whohosts = "/users/barmar/lib/whohosts.txt" unless -f $whohosts;
if (open (WHOHOSTS, "<$whohosts"))
{
  while (<WHOHOSTS>)
    {
      next if /^#/;
      if (/^(.+):(\S+)/)
	{
	  $whois_server{$1} = $2;
	}
    }
  close(WHOHOSTS)
}

$last_arg = "\L$ARGV[$#ARGV]";

($suffix) = $last_arg =~ /\.([^.]+)$/;

if ($opt_h)
{
  $whoishost = $opt_h;
} elsif ($ARGV[0] =~ /^asn?$|^net(work)?$/ || $last_arg =~ /^((asn|net)(blk)?)-[^.]+$|^(\d+.){0,2}\d+(\.0)?$|-arin$/i)
{
  if ($last_arg =~ /^20[23]\.|^21[01]\./)
    {
      $whoishost = "whois.apnic.net";
    } elsif ($last_arg =~ /^19[3-5]\.|^21[23]\./)
      {
	$whoishost = "whois.ripe.net";
      } else
	{
	  $whoishost = "whois.arin.net";
	}
} elsif ($ARGV[0] =~ /^(host|server|server)$/i)
{
  $whoishost = "whois.networksolutions.com";
} elsif ($last_arg =~ /-hst$|-dom|-org$/i)
{ 
  $whoishost = "whois.networksolutions.com";
  $ARGV[$#ARGV] = "!$last_arg";
}
  elsif ($whoishost = $whois_server{$suffix})
{
} elsif ($last_arg =~ /\.[a-z][a-z]$/)
{ # country domain, assume Europe
  $whoishost = "whois.ripe.net";
} else {
  $whoishost = "whois.networksolutions.com";
}

$sockaddr = 'S n a4 x8';
($name, $aliases, $type, $len, $thataddr) = gethostbyname($whoishost);# || die "gethostbyname($whoishost): $!\n";
die "gethostbyname($whoishost): $!\n" unless $thataddr;

$that = pack($sockaddr, &AF_INET, $port, $thataddr);
socket(S, &AF_INET, &SOCK_STREAM, $proto) || die "socket failed: $!\n";
connect(S, $that) || die "Connect failed: $!\n";
select(S); $| = 1; select(STDOUT);

if ($opt_a) { print S "-a "; }
if ($opt_r) { print S "-r "; }
if ($opt_s) { print S "-s $opt_s "; }

print S "@ARGV\n";

print <S>;


-- 
Barry Margolin, barmar at bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



More information about the bind-users mailing list