http://www.perlmonks.org?node_id=210165

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

I want to write a script to make updates to a DNS-Server. adding A records works fine - but I can t find examles for reverse-lookup updates (in-addr.arpa). I have tried things like that:
. .
my ($host,$ip,$type) = @_; my @adr = split /\./,$ip; my $revZone = "$adr[3]$adr[2].$adr[1].$adr[0].in-addr.arpa."; my $completeHostString = "$host.$DnsDomain."; my $update = Net::DNS::Update->new($DnsDomain); $update->push("pre", nxrrset("$revZone $type $completeHostString")); $update->push("update", rr_add("$revZone 86400 IN $type $completeHostS +tring")); my $res = Net::DNS::Resolver->new; $res->nameservers($DnsServer); my $reply = $res->send($update);

. . but always get "NOTZONE" as returnmessage from the DNS-server.

Thanks to all Perl Monks,
wolfgang arztmann

Replies are listed 'Best First'.
Re: net::dns::update and in-addr.arpa ??
by traveler (Parson) on Nov 04, 2002 at 18:06 UTC
    Some things to check:
    1. Do you have permission to update that zone (the w.z.y.z.in-addr.arpa zone)
    2. What are $host, $ip and $type? I guess the important one here is $type. Is it "PTR"?
    3. What is the value of $DnsDomain? Is it something like ".foo.com." (with the ".")
    4. Finally, should the Update->new() call refer to $DnsDomain or $revZone? I am not sure as I have not used Net::DNS::Update.
    HTH, --traveler
      Hi, thanks so far - but i think I have to explain my problem in more detail:
      I use the examples from net::dns::update. Adding or deleting A records works great!
      But there are no examples how to write PTR records to in-addr.arpa zones.
      i have tried syntax like those from "nsupdate" :
      update: {add} 13.13.168.192.in-addr.arpa. 86400 IN PTR testhost.foo.com.
      but with no success ! (NOTZONE RETURN CODE from DNS-Server)

      here is my example without variables:
      . my $update = Net::DNS::Update->new(foo.com); $update->push("pre", nxrrset("3.13.168.192.in-addr.arpa. PTR testhost. +foo.com.")); $update->push("update", rr_add("$3.13.168.192.in-addr.arpa. 86400 IN P +TR testhost.foo.com.")); my $res = Net::DNS::Resolver->new; $res->nameservers(nameserver.foo.com); my $reply = $res->send($update); .
      answers to the questions:
      as far as i know there shold be a "dot" after the domain name (testhost.foo.com.)
      Net::DNS::Update->new should refer to den DNS domain
      there are no right problems...

      by wolfgang
        I now believe that the issue is what I mentioned, you are not updating foo.com; you are updating in-addr.arpa. Try making that the arg to new. Also I presume the $ before the IP is a typo?

        HTH, --traveler

Re: net::dns::update and in-addr.arpa ??
by fglock (Vicar) on Nov 04, 2002 at 16:11 UTC

    I don't have experience with Net::DNS, but I think you don't need that "dot" at the end of the zone name.