named - Guardian Digital WebTool module interface to the BIND DNS server.
use named; my $named = new named($page);
This Guardian Digital WebTool module provides an interface to manipulating the BIND DNS server. This module allows you to manage forward and reverse master and slave zones and zone records such as A (address), CNAME (name alias), MX (mail exchanger), NS (nameserver), and PTR (reverse addresses).
Basic function is to write(edit) a named.conf file. It receives a hash reference of array reference of configuration parameters(allow-query,allow-transfer,listen-on etc). It reads through the named.conf file and compare parameters and values with provided parameters and ultimately updates/writes named.conf file.
Example Usage:
my $cfg = {
'allow-query' => \@allow_query,
'allow-transfer' => \@allow_transfer,
'forwarders' => \@forwarders,
'listen-on' => \@listen_on,
'forward-only' => ($forwarders[0]) ? 1 : 0,
};
$named->write_named_conf($cfg);
This function receives zone type and name as arguments. If type is 'forward' and name doesnt end with '.' then name is appended with '.'. If type is 'reverse' then name is split with '.' and splited string is concated with '.', and whole string now is concated with 'in-addr.arpa.' and returned.
Example Usage:
my $origin = $named->zone_generate_origin($type, $name);
This function basically creates a master zone in named.conf. It receives hash reference containing zone type, name, email as argument. Using these information it creates origing, email and filename values.Finally it writes out these information in named.conf.
Example Usage:
my $zone = {
'TTL' => $in{'ttl_a'} . $in{'ttl_b'},
'allow-query' => \@allow_query,
'allow-transfer' => \@allow_transfer,
'type' => $in{'type'},
'master' => $in{'master'},
'email' => $in{'email'},
'name' => $in{'zone_name'},
};
$create = $named->zone_create($zone);
This function basically updates given zone. It receives hash reference containing zone type, name, email as argument. Using zone type it generates email specific to that zone. Finally it updates named.conf and zone file too.
Example Usage:
my $zone = {
'TTL' => $in{'ttl_a'} . $in{'ttl_b'},
'allow-query' => \@allow_query,
'allow-transfer' => \@allow_transfer,
'type' => $in{'type'},
'master' => $in{'master'},
'email' => $in{'email'},
'name' => $in{'zone_name'},
};
$named->zone_update($zone);
This function is used to delete a specified zone. It receives hash reference containing zone name as argument. It reads through named.conf file and deletes that zone information. Zone file is also deleted from respective directory(master/slave).
Example Usage:
$named->zone_delete($zone);
This function is used to create a slave zone. It receives hash reference containing zone information as argument. It writes out these information in named.conf. It also creates zone file at appropriate location(slave/).
Example Usage:
my $zone = {
'allow-query' => \@allow_query,
'allow-transfer' => \@allow_transfer,
'masters' => \@masters,
'type' => $in{'type'},
'name' => $in{'zone_name'},
};
$named->zone_create_slave($zone);
This function is used to update slave zone. It receives hash reference containing zone information as argument. It updates these information in named.conf.
Example Usage:
my $zone = {
'allow-query' => \@allow_query,
'allow-transfer' => \@allow_transfer,
'masters' => \@masters,
'name' => $in{'zone_name'},
};
$named->zone_update_slave($zone);
This function receives two arguments. First argument is type(rval or lval). If type will be rval and second argument will not end with '.' then it will just append '.' at the end in second argument and return it. If type will be lval and second argument ends up with '.' then it splits second argument with '.' and returns first element of second argument.
Example Usage:
my $master = $named->record_clean('rval', $zone->{'master'});
This function basically creates a record in zone file. It receives two arguments. First argument is a hash reference containing record data and the second (optional) argument (yes or no, default is yes) dictates whether or not the zones serial number is updated.
Depending on the record type (A,CNAME,MX,NS etc) it writes out record details in appropriate zonefile.
Example Usage:
my $r = {
'zone' => $in{'zone'},
'type' => $in{'type'},
'left' => $in{'field1'},
'right' => $in{'field2'},
'weight' => $in{'field2'},
};
$named->record_create($r);
This function basically deletes a record from a zone file. It receives two arguments. First argument is a hash reference containing record data and the second (optional) argument (yes or no, default is yes) dictates whether or not the zones serial number is updated.
Depending on the record type (A,CNAME,MX,NS etc) it deletes record details from zone file.
Example Usage:
my $r = {
'zone' => $in{'zone'},
'type' => $in{'type'},
'left' => $in{'field1'},
'right' => $in{'field2'},
'weight' => $in{'field2'},
};
$named->record_delete($r);Ryan W. Maple <ryan@guardiandigital.com>
Copyright 2000-2007 Guardian Digital, Inc., All Rights Reserved