What you need to do is perform a zone transfer and extract all of the A records for the domain in question.

#!/usr/bin/perl use Net::DNS; use Socket; use strict; my $domain = shift || "foo.com"; # Create a resolver object my $res = new Net::DNS::Resolver; # Ask the local resolver what the name servers for the domain in # question. my @ns; my $query = $res->query($domain, "NS") or die "query failed; ". $res->errorstring; for my $rr ($query->answer) { next if $rr->type ne "NS"; my $dotted_quad = join(".", (unpack("C4", gethostbyname($rr->nsdname)))); print "Found name server ".$rr->nsdname." ($dotted_quad)\n"; push @ns, $dotted_quad; } $res->nameservers(@ns); # ok, now we do a zone transfer my @zoneinfo = $res->axfr($domain) or die "query failed; ". $res->errorstring; # now loop through the answers and print those that are A records for my $rr (@zoneinfo) { next if $rr->type ne "A"; print "Found ". $rr->name ." A ".$rr->address."\n"; }

An alternative method might be to process the output of the "nslookup" or "dig" commands.


In reply to Re: How can I determine all the hosts on my network? by mugwumpjism
in thread How can I determine all the hosts on my network? by Ri-Del

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.