The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CfgTie::TieNamed -- A tool to help configure the name daemon (BIND DNS server)

SYNOPSIS

This is a PERL module to help make it easy to configure the DNS name server

DESCRIPTION

This is a tie hash to the NAMED configuration files. You use it as follows:

   tie %named, 'CfgTie::TieNamed','/path/to/named.boot';
   $named = CfgTie::TieNamed->new('/path/to/named.boot');

These will set up a hash (named) to the named configuration files. It will used the specified named.boot file.

   tie %named, 'CfgTie::TieNamed';
   $named = CfgTie::TieNamed->new();

These will set up a hash (named) to the named configuration files. The files will be automatically determined from the system startup scripts.

Examples

Lets say you would like to name a bunch of machines (like modems) with a base name and a number. The number part needs to be the same as the same as the last number in the IP address. You know these go in a domain like, "wikstrom.pilec.rm.net" which is a zone for your name server:

      tie %DNS, 'CfgTie::TieNamed';
      my $Tbl = $DNS->{'primary'}->{'wikstrom.pilec.rm.net'};
      my $N=10; #Ten modems;
      my $prefix="usr2-port";
      my $ip_start=11;
      for (my $i = 0; $i < $N; $i++)
      {
         #Insert the address record in the table
         $Tbl->{$prefix.$i}->{'A'} = "127.221.19.".($i+$ip_start);
      }

      #Finally make sure that the reverse name space is up to date
      (tied %DNS)->RevXRef('wikstrom.pilec.rm.net','19.221.127.in-addr.arpa');

Even the address to name mapping will be kept up to date.

The basic structure of the named configuration table

bogusns

A list of name server addresses to ignore.

cache

See named(8) for a description

check-names
directory

This specifies the working directory of the named server, and is used in determining the location of the associated files.

forwarders

A list of other servers' addresses on the site that can be used for recursive look up.

limit

Controls operational parameters of the named server. See below.

options

The list of options the named server should adhere to.

primary

This maps to a an associative array of name spaces we are primary for. See below for more details on this is handled.

secondary

This maps to a an associative array of name spaces we are secondary for.

sortlist

See named(8) for a description

xfrnets

The list of networks which are allowed to request zone transfers. If not present, all hosts on all networks are.

Others may be set as well, but they are for backwards compatibility and should be changed to the more appopriate form. See named(8) for more information.

Extra methods for the configuration table

These are various methods you can use. Of course, you will need an object reference you can use for the remaining methods. Note that if you tied the variable, you will want to use code sorta like: my $Obj = tied %CfgTie::TieNamed;

RevSpaces Is the list of the reverses addresses spaces that the server is primary for (except loopback)

FwdSpaces Is the list of name spaces the server is primary for (except the loopback and reverse name spaces)

RevXRef($fwd,$rev) This will check that reverse look up is up to date with the primary look up. It will add reverse entries as appropriate (if there is one missing, or the value is correct). It will not change a reverse entry if there are multiple names with the same address entry. rev is optional, but this method will return (with a 0) if it is not specified and there is more than one reverse name space. fwd is optional, but this method will return (with a 0) if it is not specified and there is more than one primary name space. Returns the number of entries changed or added.

Note: This also derives any other methods from the CfgTie::Cfgfile module (CfgTie::Cfgfile).

The basic structure of a primary name space table

The $named->{primary} entry refers to a associative arrays. The keys are the domain names that are to be server. ie,

   my %mydom = $name->{primary}->{'mydomain.com'};

These associations in turn refer to a table of names and their respective attributes. The keys to this table are the machine names.

The values associated keys are hash references to domain name records. This in turn refers to another (confused yet?) associative array. The keys of this table are the DNS attribute names. The values associated with the key are list references, usually a set of possible values for the given attribute and name pair. The most common ones are:

A

This is a list reference to all of the physical addresses the given machine name has.

NS

This is a list reference to all of the servers that can serve as domain name servers.

CNAME

This is a list reference to all of the real names the given machine name has.

SOA

Has a list reference with the following structure HOSTDATAFROM MAILADDR SERIAL REFRESH RETRY EXPIRE MinTTL The Serial number is automatically updated for each table that is changed. The format is guessed (from various date formats include YYYYMMDD, YYYYDDD, and others), and properly incremented or set.

PTR

This is a list reference to the real name of a given machines address.

TXT

Each element of this list refers to a string describing the domain or name.

WKS
HINFO

Extra methods table

DblLinks This looks for entries with both a A and a CNAME entry. Keep controls whether to keep the A or the CNAME entry; the default is to keep the A entry (and delete the CNAME entry). Returns a count of all the records that were modified.

Note: This also derives any other methods from the CfgTie::Cfgfile module (CfgTie::Cfgfile).

See Also

CfgTie::Cfgfile, CfgTie::TieAliases, CfgTie::TieGeneric, CfgTie::TieGroup, CfgTie::TieHost, CfgTie::TieMTab, CfgTie::TieNet, CfgTie::TiePh, CfgTie::TieProto, CfgTie::TieRCService, CfgTie::TieRsrc< CfgTie::TieServ, CfgTie::TieShadow, CfgTie::TieUser

Caveats

Much of the information is cached and the file is updated at the end. The named process will sent the SIGHUP signal to restart and reload the configuration files.

The reverse name file can not be automatically created... Only modified.

The SOA records in the named configuration files are not easy to change.

Changing the file name or directory currently does not move the files in the file system

Author

Randall Maas (randym@acm.org)