in reply to DNS lookup

I tend to avoid gethostbyname and similar these days and instead turn to Net::DNS for all my DNS needs. Using this we can do:

#!/usr/bin/env perl use strict; use warnings; use Net::DNS; my @rr = rr ('www.perlmonks.org', 'A'); for my $rec (@rr) { next unless $rec->type eq 'A'; print "Found: " . $rec->rdstring . "\n"; }

🦛

Replies are listed 'Best First'.
Re^2: DNS lookup
by g_speran (Scribe) on Feb 14, 2023 at 17:31 UTC
    this code still only found the 192.168.100.x and not the 192.168.110.x address

      Well, if your hostname is only set up to resolve to a single IP address in your DNS then that's fine. If you want it to resolve to multiple addresses you will need to talk to your DNS maintainer and have them modify the zone so that it does (as happens with www.perlmonks.org).


      🦛

      Maybe it's a round robin setup (multiple addresses for a name, only one gets send to the client at any given time)

      Lookup type ANY should give more informations, but that also depends on the server configuration.

      PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP