Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

net::dns::update and ??

by Anonymous Monk
on Nov 04, 2002 at 13:49 UTC ( #210165=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


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 ( I have tried things like that:
. .
my ($host,$ip,$type) = @_; my @adr = split /\./,$ip; my $revZone = "$adr[3]$adr[2].$adr[1].$adr[0]"; 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 ??
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 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 "" (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 zones.
      i have tried syntax like those from "nsupdate" :
      update: {add} 86400 IN PTR
      but with no success ! (NOTZONE RETURN CODE from DNS-Server)

      here is my example without variables:
      . my $update = Net::DNS::Update->new(; $update->push("pre", nxrrset(" PTR testhost.")); $update->push("update", rr_add("$ 86400 IN P +TR")); my $res = Net::DNS::Resolver->new; $res->nameservers(; my $reply = $res->send($update); .
      answers to the questions:
      as far as i know there shold be a "dot" after the domain name (
      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; you are updating Try making that the arg to new. Also I presume the $ before the IP is a typo?

        HTH, --traveler

Re: net::dns::update and ??
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://210165]
Approved by grinder
[Corion]: erix: Yeah, I just found that it has no documentation at all on how to circumvent/ eliminate "1+n SELECTs" by building a local hash... I guess I have to make ->has_many do the hash lookup instead of doing the SQL query. But as the problem ...
[Corion]: ... has only manifested itself so far through the puzzled questions of other bystanders, I won't go deeper at this time. But the DBIx::Class documentation could well do with a document on how to make "it" (that is, ORMs in general) faster ;)
[Corion]: I find that DBIx::Class, like most ORMs makes things easy until they become performance critical and then makes it horribly hard to change things because the design is highly inflexible if you don't already know about the problems of 1+n :-/
[choroba]: that's why I don't like similar libraries. They pretend you don't have to learn SQL, but in the end, you have to learn how SQL plus to overcome their own limitations
[Corion]: "Just write the proper SQL beforehand" is of course the appropriate solution, but if you did that, you wouldn't/couldn't use DBIx::Class either. At least not in an obvious (to me) way.
choroba scratches a "how"
[Corion]: choroba: Exactly... But maybe that's just because I'm old and grumpy ;)
[Corion]: But maybe that could also be a nice talk, how to restructure your DBIx::Class-based app to remove 1+n-style query patterns
[Corion]: In theory, that should be easy because you should have the "where" clause from part 1 of the patterns and then do the corresponding single select using that where clause to select all rows in one go for the n other parts.
[Corion]: But in practice I don't see any obvious places documented in DBIx::Class where one would do that and then just feed hash lookups instead of DB lookups for ->has_many results

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-09-25 11:11 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (279 votes). Check out past polls.