g_speran has asked for the wisdom of the Perl Monks concerning the following question:
100.168.192 - has t4400-100 associated with 192.168.100.100
110.168.192 - has t4400-100 associated with 192.168.110.100
Is there a way/process, when looking up the host name of t4400-100, it will return both IP address of 192.168.100.100 & 192.168.110.100
#!/usr/bin/perl -w # hostaddrs - canonize name and show addresses use Socket; use Net::hostent; use strict; print "\nHost_Name \n"; my ($name, $hent, @addresses); $name = shift || die "usage: $0 hostname\n"; if ($hent = gethostbyname($name)) { $name = $hent->name; # in case different my $addr_ref = $hent->addr_list; @addresses = map { inet_ntoa($_) } @$addr_ref; } print "$name => @addresses\n";
Output I:\>perl dnslookup.pl t4400-202.mycompany.local Host_Name t4400-202.mycompany.local => 192.168.100.202 ( ==> wanting to show 192.168.110.202 as well <== I:\>
Discipulus changed some formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DNS lookup
by hippo (Archbishop) on Feb 14, 2023 at 16:56 UTC | |
by g_speran (Scribe) on Feb 14, 2023 at 17:31 UTC | |
by hippo (Archbishop) on Feb 14, 2023 at 18:45 UTC | |
by cavac (Prior) on Feb 15, 2023 at 12:51 UTC | |
|
Re: DNS lookup
by alexander_lunev (Pilgrim) on Feb 15, 2023 at 06:56 UTC | |
|
Re: DNS lookup
by Anonymous Monk on Feb 14, 2023 at 17:45 UTC | |
by g_speran (Scribe) on Feb 14, 2023 at 18:14 UTC |