- SEE ALSO
Parse::DNS::Zone - DNS Zone File Parser
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 ...
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:
$TTL (as described in RFC 2308)
Parse::DNS::Zone does not support $GENERATE in this version.
- Required Arguments
And additionally, exactly one of the following:
Path to the zonefile being parsed
The zone, as a string.
- Optional Arguments
If set to a true value, the parser will whine and die if the zonefile doesn't contain a SOA record. (Default: yes)
Specify a basepath, from which included relative zonefiles should be available. If used with the zonefile parameter, this defaults to the directory in which the zonefile is in. For $INCLUDEs to work when passing the zone in as a string, this needs to be specified.
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!
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'.
Returns a true value if the name exists, and false otherwise.
Returns a list with all RR types for a specific name
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".
Returns a list with all names specified in the zone
Returns the MNAME part of the SOA.
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)
Return the SERIAL value of a SOA.
Return the REFRESH value of a SOA
Return the RETRY value of a SOA
Return the EXPIRE value of a SOA
Return the MINIMUM value of a SOA
RFC 1034, RFC 1035, Bind Administrator's Guide
Latest stable version is available on CPAN. Current development version is available on https://github.com/olof/Parse-DNS-Zone, and this is the preferred place to report issues.
Copyright (c) 2009-2011, 2013, 2015 - Olof Johansson <email@example.com>
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.