PracticeDev/study_perl/dns_resolution.pl

20 lines
325 B
Perl
Raw Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/perl
use strict;
use warnings;
use Net::DNS::Resolver;
my $hostname = 'perl.org';
my $res = Net::DNS::Resolver->new(
nameservers => [qw(10.5.0.1)],
);
my $query = $res->search($hostname);
if ($query) {
foreach my $rr ($query->answer) {
next unless $rr->type eq 'A';
say "Found an A record:";
}
}