我可以通过Perl确定给定的“主机名”是否为CNAME

前端之家收集整理的这篇文章主要介绍了我可以通过Perl确定给定的“主机名”是否为CNAME前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在工作中,我有这样的事情……

$host www.something.com
www.something.com is an alias for some.other.address
some.other.address is an alias for one.more.address
one.more.address has address xxx.xxx.xxx.xxx

我想在Perl中放入www.something.com并确定它是否是CNAME,A记录等.

解决方法

use Net::DNS qw();
my $query = Net::DNS::Resolver->new->search('conferences.yapceurope.org');

if ($query) {
    foreach my $rr ($query->answer) {
        next unless 'CNAME' eq $rr->type;
        print $rr->cname;
    }
} else {
    warn sprintf "query Failed: %s\n",$res->errorstring;
}

猜你在找的Perl相关文章