Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

DNS::ZoneFile

by naChoZ (Curate)
on Jun 20, 2003 at 13:31 UTC ( #267565=perlquestion: print w/replies, xml ) Need Help??

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

Could someone help me figure out how to use DNS::ZoneFile? I've tried a few of the different modules for DNS manipulation, but I'm not having much luck. I followed this example and wrote this and tried to just get it to print one zone...

#!/usr/bin/perl -w use strict; use DNS::ZoneFile; my ($ORIGIN,$NEW_ZONE); my $zone=DNS::ZoneFile->new( "../named.master.conf/_dnsmaster", ZONE_ORIGIN=>$ORIGIN, NEW_ZONE=>$NEW_ZONE, ); $zone->printZone( "example.com" );
Running this yields:

> perl Fetchzones.pl Useless use of private variable in void context at /usr/local/lib/perl +5/site_perl/5.6.1/DNS/ZoneFile.pm line 115. Use of implicit split to @_ is deprecated at /usr/local/lib/perl5/site +_perl/5.6.1/DNS/ZoneFile.pm line 220. Use of implicit split to @_ is deprecated at /usr/local/lib/perl5/site +_perl/5.6.1/DNS/ZoneFile.pm line 240. Use of implicit split to @_ is deprecated at /usr/local/lib/perl5/site +_perl/5.6.1/DNS/ZoneFile.pm line 260. Explicit blessing to '' (assuming package main) at /usr/local/lib/perl +5/site_perl/5.6.1/DNS/ZoneFile.pm line 133. Can't locate object method "readZoneFile" via package "main" (perhaps +you forgot to load "main"?) at /usr/local/lib/perl5/site_perl/5.6.1/D +NS/ZoneFile.pm line 139.

Not sure how to interpret this error message...

What I'm trying to accomplish is to make a script to read a bind 8 named.conf file and tell me the filename for each master zone.

~~
naChoZ

Replies are listed 'Best First'.
Re: DNS::ZoneFile
by gellyfish (Monsignor) on Jun 20, 2003 at 13:37 UTC

    Er, I think you will probably want to read what it says in the README:

    *** THIS CODE IS NOT FINISHED ***
    
    This doesn't implement anything like the same interface
    that the previous version did. In fact a large amount of
    the interface and API code remains unwritten because it's
    been sitting on my hard disc for the last 6 months. I have
    been persuaded to release unfinished code to the community
    (yes, greg, you managed to persuade me). So here it is if
    you want to play with it.
    
    
    and then get the previous version. The release of this version was the result of a very drunken night after yapc::Europe 2000 ....

    /J\
    
      Great, thanx. I was only reading the perldoc, which contains a small mention of being unfinished. Since someone here recommended it I thought it might just be lacking other features or something.

      ~~
      naChoZ

Re: DNS::ZoneFile^H^H^H^HParse
by simonflk (Pilgrim) on Jun 20, 2003 at 16:38 UTC

    You could try DNS::ZoneParse:

    #!/usr/bin/perl -w use strict; use DNS::ZoneParse; my $zone = DNS::ZoneParse->new("../named.master.conf/_dnsmaster"); print $zone->output();

    Update: Missed the question -- This won't parse the named.conf file. Looks like BIND::Conf_Parser should do what you want

    -- simonflk

      I gave that one a quick spin. But the one that I actually got working pretty easily is Unix::Conf::Bind8.

      For possible future super searchers, this is all it took:

      #!/usr/bin/perl -w use strict; use Unix::Conf::Bind8; my $namedconf='/path_to/named.conf'; my ($obj, $conf); $conf = Unix::Conf::Bind8->new_conf ( FILE => $namedconf, SECURE_OPEN => 0 ) or $conf->die ('could not open \'named.conf\':' . $!); $obj = $conf->get_zone ('example.com') or $obj->die ("couldn't get zone `example.com'"); print "\n" . $obj->file . "\n";

      ~~
      naChoZ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2022-05-24 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?