DnsServerAPI - DNS server configuration functional API
This package is the public functional YaST2 API to configure the Bind version 9
in Perl
use DnsServerAPI;
my $categories = DnsServerAPI->GetLoggingCategories()
;
in YCP imoprt "DnsServerAPI"; list <string> categories = DnsServerAPI::GetLoggingCategories();
Note: All arrays or hashes returned or accepted by this module are references to them. However it is impossible to change the data through the references, because the references are, actually, references to copies of the data.
$integer = TimeToSeconds($string);
Gets the BIND time parameter and transforms it into seconds.
EXAMPLE:
my $time = TimeToSeconds("1W2d4H");
$string = SecondsToHighestTimeUnit($integer);
Gets the time in seconds and returns BIND time format with the highest possible time unit selected.
EXAMPLE:
my $bind_time = SecondsToHighestTimeUnit(259200); -> "3D"
$boolean = Read($time);
Reads current BIND configuration.
EXAMPLE:
my $success = Read();
$boolean = Write($time);
Writes current BIND configuration.
EXAMPLE:
my $success = Write();
@array = GetForwarders();
Returns list of general DNS forwarders.
EXAMPLE:
my $list_of_forwarders = GetForwarders();
$boolean = AddForwarder($ipv4);
Adds a new forwarder into the list of current forwarders.
EXAMPLE:
my $success = AddForwarder($forwarder_ip);
$boolean = RemoveForwarder($ipv4);
Removes forwarder from the list of current forwarders.
EXAMPLE:
my $success = RemoveForwarder($forwarder_ip);
$boolean = IsLoggingSupported();
Checks whether the current configuration is supported by functions for getting or changing configuration by this module. User should be warned that his configuration could get demaged if he change it by this module.
Only one logging channel is supported.
EXAMPLE:
my $is_supported = IsLoggingSupported($forwarder_ip);
$hash = GetLoggingChannel();
Returns hash with current logging channel.
EXAMPLE:
my $channel = GetLoggingChannel(); if ($channel->{'destination'} eq 'syslog') { print "logging to syslog is used"; } elsif ($channel->{'destination'} eq 'file') { print "logging to file is used\n". " File: ".$channel->{'filename'}. " Max. Versions: ".$channel->{'versions'}. " Max. Size: ".$channel->{'size'}; }
$boolean = SetLoggingChannel($hash);
Returns hash with current logging channel.
EXAMPLE:
if ($log_to_syslog) { $success = SetLoggingChannel( 'destination' => 'syslog' ); } else { $success = SetLoggingChannel( 'destination' => 'file', 'filename' => '/var/log/named.log', 'versions' => '8', 'size' => '10M', ); }
$array = GetLoggingCategories();
Returns list of used logging categories.
EXAMPLE:
my $categories = GetLoggingCategories(); foreach my $category (@{$categories}) { print "Using category: ".$category."\n"; }
$boolean = SetLoggingCategories($array);
Returns list of used logging categories.
EXAMPLE:
my @categories = ('default', 'xfer-in'); my $success = SetLoggingCategories(\@categories);
$hash = GetACLs();
Returns hash of possible ACLs.
EXAMPLE:
my $acls = GetACLs(); foreach $acl_name (keys %{$acls}) { if (defined $acls->{$acl_name}->{'default'}) { # names: 'any', 'none', 'localnets', 'localips' print "Default: ".$acl_name."\n"; } else { print "Custom: ".$acl_name." ". "Value: ".$acls->{$acl_name}->{'value'}."\n"; } }
$hash = GetZones($string);
Returns all DNS zones administered by this DNS server.
EXAMPLE:
my $zones = GetZones(); foreach my $zone (keys %{$zones}) { print "Zone Name: ".$zone." ". "Zone Type: ".$zones->{$zone}->{'type'}."\n"; # 'master' or 'slave' }
$array = GetZoneMasterServers($string);
Returns list of master servers assigned to this slave zone. Master zones do not have any master servers defined.
EXAMPLE:
my $zone = 'example.org'; foreach my $server @(GetZoneMasterServers($zone)) { print "Zone ".$zone." uses ".$server." master server\n"; }
$boolean = SetZoneMasterServers($string,$array);
Sets masterservers for slave zone.
EXAMPLE:
my @masterservers = ('192.168.32.1','192.168.32.2'); my $zone = 'example.org'; my $success = SetZoneMasterServers($zone, \@masterservers);
$boolean = AddZone($string,$string,$hash);
Function creates new DNS zone. Option 'masterserver' is needed for 'slave' zone.
EXAMPLE:
# 'master' zone $success = AddZone( 'example.org', # zone name 'master', # zone type {} # without options ); # 'slave' zone $success = AddZone( 'example.org', # zone name 'slave', # zone type { # 'masterserver' must be defined for 'slave' zone 'masterserver' => '192.168.64.2' } );
$boolean = RemoveZone($string);
Function removes a zone.
EXAMPLE:
$success = RemoveZone('example.org');
$array = GetZoneTransportACLs($string);
Function returns list of ACLs used for Zone Transportation.
EXAMPLE:
my $acls = GetZoneTransportACLs('example.org'); foreach my $acl_name (@{$acls}) { print "ACL used: ".$acl_name."\n"; }
$boolean = AddZoneTransportACL($string,$string);
Adds ACL into ACLs allowed for Zone Transportation. ACL must be known (default or custom).
EXAMPLE:
my $success = AddZoneTransportACL('example.org','localnets');
$boolean = RemoveZoneTransportACL($string,$string);
Removes ACL from ACLs allowed for Zone Transportation. ACL must be known (default or custom).
EXAMPLE:
my $success = RemoveZoneTransportACL('example.org','localnets');
$array = GetZoneNameServers($string);
Function returns list of Zone Name Servers. Only Zone base name servers are returned.
EXAMPLE:
my $nameservers = GetZoneNameServers('example.org');
$array = GetZoneMailServers($string);
Function returns list of hashes of Zone Mail Servers. Only Zone base mail servers are returned.
EXAMPLE:
my $mailservers = GetZoneMailServers('example.org'); foreach my $mailserver (@{$mailservers}) { print "Mail Server: ".$mailserver->{'name'}." ". "Priority: ".$mailserver->{'priority'}; }
$array = GetZoneRRs($string);
Returns list of hashes with all zone records inside. Base Zone Name and Mail Servers are filtered out.
EXAMPLE:
my $records = GetZoneRRs('example.org'); foreach my $record (@{$records}) { print "Record:\n". " Key: ".$record->{'key'}."\n". # DNS Query " Type: ".$record->{'type'}."\n". # Resource Record Type " Value: ".$record->{'value'}."\n"; # DNS Reply }
$boolean = AddZoneRR($string,$string,$string,$string);
Adds Zone Resource Record.
EXAMPLE:
# absolute hostname $success = AddZoneRR( 'example.org', # zone name 'A', # record type 'dhcp25.example.org.', # record key / DNS query '192.168.2.25', # record value / DNS reply );
# hostname relative to the zone name $success = AddZoneRR( '2.168.192.id-addr.arpa', # zone name 'PTR', # record type '25', # record key / DNS query 'dhcp25.example.org.', # record value / DNS reply );
$boolean = RemoveZoneRR($string,$string,$string,$string);
Removes Zone Resource Record.
EXAMPLE:
# absolute hostname $success = RemoveZoneRR( 'example.org', # zone name 'A', # record type 'dhcp25.example.org.', # record key / DNS query '192.168.2.25', # record value / DNS reply );
# hostname relative to the zone name $success = RemoveZoneRR( '2.168.192.id-addr.arpa', # zone name 'MX', # record type '2.168.192.id-addr.arpa.', # record key / DNS query '10 mx1.example.org.', # record value / DNS reply );
$boolean = AddZoneNameServer($zone,$nameserver);
Adds zone nameserver into the zone.
EXAMPLE:
# relative name of the nameserver to the zone name $success = AddZoneNameServer('example.org','ns1'); # absolute name of the nameserver ended with a dot $success = AddZoneNameServer('example.org','ns2.example.org.');
$boolean = RemoveZoneNameServer($zone,$nameserver);
Removes zone nameserver from the zone.
EXAMPLE:
# relative name of the nameserver to the zone name $success = RemoveZoneNameServer('example.org','ns2'); # absolute name of the nameserver ended with a dot $success = RemoveZoneNameServer('example.org','ns1.example.org.');
$boolean = AddZoneMailServer($zone,$mailserver,$priority);
Adds zone nameserver into the zone.
EXAMPLE:
# relative name of the mailserver to the zone name $success = AddZoneMailServer('example.org','mx1',0); # absolute name of the mailserver ended with a dot $success = AddZoneMailServer('example.org','mx2.example.org.',5555);
$boolean = RemoveZoneMailServer($zone,$mailserver,$priority);
Removes zone mailserver from the zone.
EXAMPLE:
# relative name of the mailserver to the zone name $success = RemoveZoneMailServer('example.org','mx1',0); # absolute name of the mailserver ended with a dot $success = RemoveZoneMailServer('example.org','mx2.example.org.',5555);
$hash = GetZoneSOA($zone);
Adds zone nameserver into the zone.
EXAMPLE:
# relative name of the mailserver to the zone name my $SOA = GetZoneSOA('example.org'); foreach my $key ('minimum', 'expiry', 'serial', 'retry', 'refresh', 'mail', 'server', 'ttl') { print $key."=".$SOA->{$key}."\n"; }
$hash = SetZoneSOA($zone, $soa);
Adds zone nameserver into the zone.
EXAMPLE:
# relative name of the mailserver to the zone name my $SOA = { 'minimum' => '1d1H', 'expiry' => '1W2d', 'serial' => '1998121001', 'retry' => '3600', 'refresh' => '3h5M4S', 'mail' => 'root.ns1.example.org.', 'server' => 'ns1.example.org.', 'ttl' => '2d1h', }; my $success = SetZoneSOA('example.org', $SOA);
$reversezone = GetReverseZoneNameForIP($hostname);
Returns reverse zone for IPv4 if such zone is administered by this DNS server.
EXAMPLE:
my $reversezone = GetReverseZoneNameForIP('192.168.58.12');
$reverseip = GetReverseIPforIPv4($ipv4);
Returns reverse ip for IPv4.
EXAMPLE:
my $reverseip = GetReverseIPforIPv4('192.168.58.12'); -> '12.58.168.192.id-addr.arpa'
$reverseip = GetFullIPv6($ipv6);
Returns full-length ip IPv6.
EXAMPLE:
my $reverseip = GetFullIPv6('3ffe:ffff::1'); -> '3ffe:ffff:0000:0000:0000:0000:0000:0001' my $reverseip = GetFullIPv6('3ffe:ffff::210:a4ff:fe01:1'); -> '3ffe:ffff:0000:0000:0210:a4ff:fe01:0001' my $reverseip = GetFullIPv6('3ffe:ffff::'); -> '3ffe:ffff:0000:0000:0000:0000:0000:0000' my $reverseip = GetFullIPv6('::25'); -> '0000:0000:0000:0000:0000:0000:0000:0025'
$reverseip = GetReverseIPforIPv6($ipv6);
Returns reverse ip for IPv6.
EXAMPLE:
my $reverseip = GetReverseIPforIPv6('3ffe:ffff::1'); -> '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.f.f.f.e.f.f.3.ip6.arpa.' my $reverseip = GetReverseIPforIPv6('3ffe:ffff::210:a4ff:fe01:1'); -> '1.0.0.0.1.0.e.f.f.f.4.a.0.1.2.0.0.0.0.0.0.0.0.0.f.f.f.f.e.f.f.3.ip6.arpa.' my $reverseip = GetReverseIPforIPv6('3ffe:ffff::'); -> '0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.f.f.f.e.f.f.3.ip6.arpa.'
$reverseip = GetCompressedIPv6($ipv6);
Returns compressed IPv6.
EXAMPLE:
my $compressed = GetCompressedIPv6('3ffe:ffff:0000:0000:0000:0000:0000:0001'); -> '3ffe:ffff::1' my $compressed = GetCompressedIPv6('3ffe:ffff:0000:0000:0210:a4ff:fe01:0001'); -> '3ffe:ffff::210:a4ff:fe01:1' my $compressed = GetCompressedIPv6('3ffe:ffff:0000:0000:0000:0000:0000:0000'); -> '3ffe:ffff::' my $compressed = GetCompressedIPv6('0000:0025:0000:0000:0000:0000:0000:0000'); -> '0:25::' my $compressed = GetCompressedIPv6('0000:0000:0000:0025:0000:0025:0000:0000'); -> '::25:0:25:0:0'
$reverseip = AddHost($zone, $hostname, $ipv4);
Function adds forward and reverse records into the administered zones. Zones must be both defined and they must be 'master's for the zone.
EXAMPLE:
$success = AddHost('example.org','dhcp25','192.168.58.25'); $success = AddHost('example.org','dhcp27.example.org.','192.168.58.27');
$boolean = RemoveHost($zone, $hostname, $ipv4);
Function removes forward and reverse records from the administered zones. Forward zone must be defined, reverse zone is not needed. Both zones must be administered by this DNS server ('master's);
EXAMPLE:
$success = RemoveHost('example.org','dhcp25.example.org.','192.168.58.25'); $success = RemoveHost('example.org','dhcp27','192.168.58.27');
$reverseip = GetZoneHosts($zone);
Returns list of Zone Hosts which have the forward and also the reverse record administered by this DNS server. If zone is not set, all zones administered by this DNS server would be checked.
EXAMPLE:
my $hosts = GetZoneHosts(); foreach my $host (@{$hosts}) { print "zone: ".$host->{'zone'}." ". "hostname: ".$host->{'key'}." ". "ipv4: ".$host->{'value'}; }
$array = GetZoneForwarders($string);
Function returns list of zone forwarders.
EXAMPLE:
$list_of_forwarders = GetZoneForwarders('example.org');
$boolean = SetZoneForwarders($string, $array);
Function sets forwarders for the zone.
EXAMPLE:
my @forwarders = SetZoneForwarders('192.168.32.1','192.168.32.2'); my $zone = 'example.org'; my $success = SetZoneForwarders($zone, \@masterservers);
$boolean = ServiceIsConfigurableExternally();
Checks whether the needed DNS Server package is installed and whether the server is enabled, or at least, running.
EXAMPLE:
my $configurable = IsServiceConfigurableExternally()