DNS Resolver

Posted by Jason Noble on 08/19/2008 in dns, perl |

I had a list of domains that needed their MX records updated. I first wanted to make sure that our DNS servers were authoritative for those zones.

I used Perl and the Net::DNS CPAN module to figure out the NS records for each domain.


use Net::DNS;

my $resolver = Net::DNS::Resolver->new;
my $query = "";
my $domain = "";

open(FILE, "</tmp/domains.txt");
while(<file>) {
  $domain = $_;
  $query = $resolver->query($domain, "NS");
  print $domain;
  if($query) {
    foreach my $rr ($query->answer) {
      next unless $rr->type eq "NS";
      print ",", $rr->nsdname;
    print "\n";
  } else {
    print ",DOES NOT RESOLVE\n";

Copyright © 2008-2018 Jason Noble's Technical Adventures All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.2.3, from BuyNowShop.com.