Olof Johansson > Parse-DNS-Zone > Parse::DNS::Zone

Download:
Parse-DNS-Zone-0.42.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.42   Source  

NAME ^

Parse::DNS::Zone - DNS Zone File Parser

SYNOPSIS ^

 use Parse::DNS::Zone;

 my $pdz = Parse::DNS::Zone->new(
        zonefile=>'db.example',
        origin=>'example.org.',
 );

 my $a_rr = $pdz->get_rdata(name=>'foo', rr=>'A');
 my $mx_rr = $pdz->get_rdata(name=>'@', rr=>'MX'); # Get the origin's MX

 # Getting SOA values
 my $mname = $pdz->get_mname();
 my $rname = $pdz->get_rname();
 my $serial = $pdz->get_serial();
 # ... etc ...

DESCRIPTION ^

Parse::DNS::Zone parses a zonefile, used to define a DNS Zone and gives you the information therein, via an object oriented interface. Parse::DNS::Zone doesn't validate rrdata, except for SOA, and is used to 1) validate the basic structure of the file and 2) extract rdata so you can parse it and validate it yourself.

Parse::DNS::Zone supports the zone file format as described in RFC 1034:

Parse::DNS::Zone does not support $GENERATE in this version.

CONSTRUCTOR ^

Parse::DNS::Zone->new( ARGS )

Required Arguments
  • origin

    Origin

  • zonefile

    Path to the zonefile being parsed

Optional Arguments
  • require_soa

    If set to a true value, the parser will whine and die if the zonefile doesn't contain a SOA record. (Default: yes)

  • append_origin

    If set to a true value, the parser will append the origin to all unqualified domain names (in certain record types, currently: CNAME, MX, NS, AFSDB, PTR). If some record types are missing from this list, please report that as a bug. (Default: no)

    This feature do run the risk of becoming stale if new record types are introduced. But if you run into problems, don't hesitate to report it!

METHODS ^

General

$pdz->get_rdata(name=>$name, rr=>$rr, n=>$n, field=>$field)

Is used to get the data associated with a specific name and rr type. The $name can be as the name appears in the zonefile, or a fqdn (with trailing .) as long as it is tracked by the zonefile. If the n argument is specified, the n:th RR in the RRset is returned. Otherwise, you'll get a complete list of the RRset if you're in list context, or the first RR if you're in scalar context.

The $field is the particular component of the resource record to return. It defaults to 'val', which is the actual value of the record. Other possibilities are 'class' (e.g. "IN") and 'ttl'.

$pdz->exists($name)

Returns a true value if the name exists, and false otherwise.

$pdz->get_rrs($name)

Returns a list with all RR types for a specific name

$pdz->get_dupes(name=>$name, rr=>$rr)

Returns how many RRs of a given type is defined for $name. For a simple setup with a single RR for $name, this will return 1. If you have some kind of load balancing or other scheme using multiple RRs of the same type this sub will return the number of "dupes".

$pdz->get_names( )

Returns a list with all names specified in the zone

SOA

$pdz->get_mname( )

Returns the MNAME part of the SOA.

$pdz->get_rname( parse=>{0,1} )

Return the RNAME part of the SOA. If parse is set to a value other than 0, the value will be interpreted to show an emailaddress. (default: 0)

$pdz->get_serial( )

Return the SERIAL value of a SOA.

$pdz->get_refresh( )

Return the REFRESH value of a SOA

$pdz->get_retry( )

Return the RETRY value of a SOA

$pdz->get_expire( )

Return the EXPIRE value of a SOA

$pdz->get_minimum( )

Return the MINIMUM value of a SOA

SEE ALSO ^

RFC 1034, RFC 1035, Bind Administrator's Guide

AVAILABILITY ^

Latest stable version is available on CPAN. Current development version is available on https://github.com/olof/Parse-DNS-Zone.

COPYRIGHT ^

Copyright (c) 2009-2011 - Olof Johansson <olof@cpan.org>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: