use Net::DNS; $res = new Net::DNS::Resolver; warn "Net::DNS error $@\n" if $@; # on some systems without the required config files you will need to # direct Net::DNS to your DNS nameserver(s) or it will timeout $res->nameservers( $prinary_nameserver_ip_address, $secondary... ) if $res; sub dns_query { return undef unless $res; my $domain = shift; $packet = $res->send($domain, 'MX') or warn $res->errorstring; return 1 if $packet->header->ancount; my $packet = $res->send($domain, 'A') or warn $res->errorstring; return 1 if $packet->header->ancount; return 0; } print "OK DNS $domain" if dns_query($domain); #### sub dns_query { return undef unless $res; my $domain = shift; for my $dns ( 'MX', 'A' ) { $packet = $res->send($domain, $dns ) or warn $res->errorstring; return 1 if $packet->header->ancount; } return 0; }