The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DNS::ZoneFile - Object management of a DNS Zone

SYNOPSIS

use DNS::ZoneFile;

$zone=DNS::ZoneFile->new(zonefilename,args...);

@arr=$zone->getRecord(name,type);

$zone->addRecord(name,type,data...);

$zone->delRecord(name,type);

$zone->sortZone();

$zone->updateSerial();

$zone->serial();

print $zone->printZone();

DESCRIPTION

The DNS::ZoneFile module provides for users to manipulate a DNS Zone database using an object oriented model. The DNS::ZoneFile object is a store for lots of DNS::ZoneFile::Record objects, and can manipulate some of the more useful bits of the zone file, such as updateSerial.

Object methods for the DNS::ZoneFile object:

new(file,args...)

The new() method takes as its argument the name of a zone file to read in, this builds the zone database into memory. You must call this before trying to use any of the methods below. I know that I should do this in a non file-based way, and I'll probably do that in the next release. The args are used to populate a hash of preferences. So far the only key that is supported is AllNames, which, if set to true will print out all of the names in the printZone() method, instead of blank spacing them.

getRecord(name,type)

The getRecord() method will try to get all of the records matching a full (canonical) name with an optional type argument, such that you might do, for example $zone->getRecord('codix.net.', 'mx');

addRecord(name,type,data...)

The addRecord() method is exactly that, it does minimal checking, except that it won't allow you to add a SOA record, as there should only ever be one of those per zone file. The data is in most cases just one address, unless the record is an MX record, in which case the first argument is the MX cost.

delRecord(name,type)

The delRecord method deletes a record from the zone database. The type argument is optional, if missed, it will delete all records matching the supplied name.

sortZone()

sortZone is called automatically whenever a printZone() is called. It sorts the zone file into a reasonable order, to be able to print. It will also make sure that the start of authority for the zone is at the top of the file.

updateSerial()

updateSerial is just that, it updates the serial number for the database for an edit.

serial()

A read only method to read the serial number for this zone.

printZone()

printZone returns the zone file as sorted and updated, in a form which you can then just output to the zone file, with the correct start of authority record.

COMMENTS

This is currently alpha software, internal structures are likely to change at any time.

AUTHOR

Matthew Byng-Maddick <matthew@codix.net>

SEE ALSO

DNS::ZoneFile::Record,bind(8)