For address family independent DNS lookups, I used this as a test for IPv6 support in Perl. This may not be the most elegant way of doing it, but it returns both IPv4 and IPv6 addresses for my local workstation and domain names you enter.

# On Windows without modifying Socket compilation use Socket qw(inet_ntoa unpack_sockaddr_in IPPROTO_TCP AF_INET AF_UNSP +EC); use Socket6; use Socket::GetAddrInfo qw(getaddrinfo getnameinfo); # OR just this with Socket modified - http://vinsworldcom.blogspot.com +/2012/08/ipv6-in-perl-on-windows_20.html use Socket 2.005 qw(:addrinfo inet_ntoa inet_ntop unpack_sockaddr_in u +npack_sockaddr_in6 IPPROTO_TCP AF_INET AF_UNSPEC); use Sys::Hostname; if (!@ARGV) { $ARGV[0] = hostname; } my %hints = ( family => AF_UNSPEC, protocol => IPPROTO_TCP ); my ($err, @getaddr) = getaddrinfo($ARGV[0], undef, \%hints); if (defined($getaddr[0])) { for my $addr (@getaddr) { my $address; if ($addr->{family} == AF_INET) { (undef, $address) = unpack_sockaddr_in($addr->{addr}) } else { (undef, $address) = unpack_sockaddr_in6($addr->{addr}) } my $host = inet_ntop($addr->{family}, $address); print "$host\n"; if (0) { # set to 1 to do reverse lookup my ($err, $host, $service) = getnameinfo($addr->{addr}, NI +_NAMEREQD); printf " |_> %s\n", (defined($host)) ? $host : $err } } } else { print "$0: getaddrinfo() failed - error = $err\n" }

And the results (note my local IPv6 addresses obscured with XXXX ...):

VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl fe80::WWWW:XXXX:YYYY:ZZZZ fe80::WWWW:XXXX:YYYY:ZZZZ fe80::WWWW:XXXX:YYYY:ZZZZ AAAA:BBBB:CCCC:DDDD:WWWW:XXXX:YYYY:ZZZZ fe80::WWWW:XXXX:YYYY:ZZZZ fe80::WWWW:XXXX:YYYY:ZZZZ 192.168.12.1 192.168.58.1 192.168.10.102 10.200.200.254 10.100.100.254 192.168.100.254 VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl www.google.com 2001:4860:800a::6a 173.194.73.106 173.194.73.147 173.194.73.99 173.194.73.104 173.194.73.105 173.194.73.103

In reply to Re: How to get wildcard addresses using getaddrinfo? by VinsWorldcom
in thread How to get wildcard addresses using getaddrinfo? by sushant.ravale

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.