Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to be able to determine the DNS details (primary/secondary DNS servers & IPs) for an arbitrary domain.

Searching thru previous posts I've come across Gandi::WhoisExtract and Net::Whois which seem to be designed for common TLDs like .net or .com.

I want something that works with arbitrary domains eg toyota.co.jp getty.musuem

Replies are listed 'Best First'.
Re: Whois & DNS information
by ercparker (Hermit) on Jul 10, 2004 at 06:49 UTC
    using Net::DNS and one of the example domains you gave I was able to query the DNS servers:
    You can get more information regarding Net::DNS on cpan website.
    use Net::DNS; my $res = Net::DNS::Resolver->new; my $query = $res->query("toyota.co.jp", "NS"); if ($query) { foreach $rr (grep { $_->type eq 'NS' } $query->answer) { print $rr->nsdname, "\n"; } } else { warn "query failed: ", $res->errorstring, "\n"; } __output__ royal.tns.ne.jp ns1a.toyota.co.jp ns1b.toyota.co.jp crown.tns.ne.jp majesta.tns.ne.jp
    Then you can query the A record for the resulting host names using Net::DNS
    or use perl function gethostbyname like this:
    my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname("roya +l.tns.ne.jp"); my (@data) = unpack('C4', $addrs[0]); my $ip = join '.', @data;
    Hope that helps you
Re: Whois & DNS information
by gaal (Parson) on Jul 10, 2004 at 06:27 UTC
    This talk by Roman Parparov of the Israeli Space Agency in TAU might be of use to you.