Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Parsing Zonefiles

by Elijah_A (Novice)
on Aug 06, 2004 at 06:24 UTC ( [id://380459]=note: print w/replies, xml ) Need Help??


in reply to Parsing Zonefiles

I got only one result out of this one:
"3. 7200 IN PTR gov.ph."
#!/usr/bin/perl use strict; use warnings; use Net::DNS; use lib "/home/postgres/elijah/govph/tests/Net"; use Net::DNS::ZoneFile; my $rrset = Net::DNS::ZoneFile->read("/home/postgres/elijah/govph/etc/ +namedb/tem p.gov.ph"); print $_->string, "\n" for @$rrset; push @$rrset, new Net::DNS::RR "3 7200 IN PTR gov.ph."; foreach (@$rrset) { next unless $_->type eq 'SOA' and $_->class eq 'IN'; $_->serial($_->serial + 1); } print $_->string, "\n" for @$rrset;
What am I doing wrong?? I should be getting something like this right?:
; Sta. Magdalena, Sorsogon ; Created by GovPh: Fri Aug 6 13:02:54 2004 stamagdalena IN NS ncc.xx.gov.ph IN NS ncc.xx.gov.ph

Replies are listed 'Best First'.
Re^2: Parsing Zonefiles
by fokat (Deacon) on Aug 10, 2004 at 05:39 UTC

    Hi Elijah_A:

    I believe the problem might be your source file. Are you sure it is a real BIND zone? Your example does not have a SOA record, which might be ok for your scenario.

    On my side, the code below (slight modification of yours)...

    #!/usr/bin/perl use strict; use warnings; use Net::DNS; use Net::DNS::ZoneFile; my $rrset = Net::DNS::ZoneFile->readfh(*DATA); print "Just read:\n"; print $_->string, "\n" for @$rrset; push @$rrset, new Net::DNS::RR "3 7200 IN PTR gov.ph."; foreach (@$rrset) { next unless $_->type eq 'SOA' and $_->class eq 'IN'; $_->serial($_->serial + 1); } print "After adding one to the SOA's serial:\n"; print $_->string, "\n" for @$rrset; __DATA__ ; Sta. Magdalena, Sorsogon ; Created by GovPh: Fri Aug  6 13:02:54 2004 stamagdalena IN NS ncc.xx.gov.ph IN NS ncc.xx.gov.ph

    Produces the following output...

    Just read:
    stamagdalena.   0       IN      NS      ncc.xx.gov.ph.
    stamagdalena.   0       IN      NS      ncc.xx.gov.ph.
    After adding one to the SOA's serial:
    stamagdalena.   0       IN      NS      ncc.xx.gov.ph.
    stamagdalena.   0       IN      NS      ncc.xx.gov.ph.
    3.      7200    IN      PTR     gov.ph.
    

    I would check the source file for extraneous characters. For the record, this is what I'm running on my side:

    $ perl -MNet::DNS::ZoneFile -e 'print $Net::DNS::ZoneFile::VERSION, "\n"'
    1.10
    $ perl -v | egrep darwin
    This is perl, v5.8.1 built for darwin
    

    Best regards

    -lem, but some call me fokat

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://380459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found