YaPI::DNSD - DNS server configuration API
This package is the public YaST2 API to configure the Bind version 9
use YaPI::DNSD
$status = StopDnsService($config)
$status = StartDnsService($config)
$status = GetDnsServiceStatus($config)
$options = ReadGlobalOptions($config)
$ret = WriteGlobalOptions($config,$options)
$zones = ReadZones($config)
$ret = WriteZones($config,$zones)
The $config
parameter is always a refernece to a hash, that contains various
configuration options. Currently following keys are supported:
"use_ldap"
says if settings should be written/read to LDAP or not. Possible values are
1 (use LDAP if configured properly) or 0 (do not use LDAP).
If not specified, mode is detected automatically.
"ldap_passwd"
holds the LDAP password needed for authentication against the LDAP server.
Needed only for writing operation if LDAP is used for data storing.
$status = StopDnsService($config);
Immediatelly stops the DNS service. Returns nonzero if operation succeeded, zero if operation failed.
EXAMPLE:
my $status = StopDnsService ({}); if ($status == 0) { print "Stopping DNS server failed"; } else { print "Stopping DNS server succeeded"; }
$status = StartDnsService ($config);
Immediatelly starts the DNS service. Returns nonzero if operation succeeded, zero if operation failed.
EXAMPLE:
my $status = StartDnsService ({}); if ($status == 0) { print "Starting DNS server failed"; } else { print "Starting DNS server succeeded"; }
$status = GetDnsServiceStatus ($config);
Check if DNS service is running. Returns nonzero if service is running, zero otherwise.
EXAMPLE:
my $status = GetDnsServiceStatus ({}); if ($status == 0) { print "DNS server is not running"; } else { print "DNS server is running"; }
$options = ReadGlobalOptions ($config);
Reads all global options of the DNS server.
Returns a list of hashes, each with keys "key" and "value", on success. Returns undef on fail.
EXAMPLE:
my $options = ReadGlobalOptions ({}); if (! defined ($options)) { print "Reading options failed"; } else { foreach my $option (@{$options}) { my $key = $option->{"key"}; my $value = $option->{"value"}; print "Have global option $key with value $value"; } }
Prints all options adjusted to tbe specified declaration.
$ret = WriteGlobalOptions ($config, $options);
Writes all global options of the DNS server. The taken argument has the same structure as return value of ReadGlobalOptions function.
Returns nonzero on success, zero on fail.
EXAMPLE:
my $options = [ { "key" => "dump-file", "value" => "\"/var/log/named_dump.db\"", }, { "key" => "statistics-file", "value" => "\"/var/log/named.stats\"", }, ] $success = WriteGlobalOptions ({}, $options);
$zones = ReadZones ($config);
Reads all zones of the DNS server.
Retuns list of configured zones, each represented as a hash, on success. The hash representing a zone is described below. On fail, returns undef.
EXAMPLE:
my $zones = ReadZones ({}); if (! defined ($zones)) { print ("Could not read zones"); } else { my $count = @{$zones}; print "Maintaining $count zones"; }
This prints the cound of zones maintained by the DNS server.
$ret = WriteZones ($config,$zones);
Writes all zones to the DNS server, removes zones that are not mentioned in the argument. The structrure of the argument is clear from the example below.
Returns nonzero on success or zero on fail.
EXAMPLE:
my $zones = [ { 'options' => [ { 'value' => 'master', 'key' => 'type' }, { 'value' => '"localhost.zone"', 'key' => 'file' } ], 'zone' => 'localhost', 'ttl' => '1W', 'records' => [ { 'value' => '127.0.0.1', 'type' => 'A', 'key' => 'localhost.' }, { 'value' => '@', 'type' => 'NS', 'key' => 'localhost.' } ], 'file' => 'localhost.zone', 'type' => 'master', 'soa' => { 'minimum' => '1W', 'expiry' => '6W', 'serial' => 2004012701, 'zone' => '@', 'retry' => '4H', 'refresh' => '2D', 'mail' => 'root', 'server' => '@' } } ]; WriteZones ({}, $zones);
This removes all DNS zones, and writes the specified zone (in this case only one).