1. DnsServerAPI

This package is the public functional YaST2 API to configure the Bind version 9

1.1. List of Global Functions

1.2. Functions

1.2.1. $integer = TimeToSeconds($string);

Gets the BIND time parameter and transforms it into seconds.

Example 1. 

    my $time = TimeToSeconds("1W2d4H");

1.2.2. $string = SecondsToHighestTimeUnit($integer);

Gets the time in seconds and returns BIND time format with the highest possible time unit selected.

Example 2. 

    my $bind_time = SecondsToHighestTimeUnit(259200);
    -> "3D"

1.2.3. $boolean = Read($time);

Reads current BIND configuration.

Example 3. 

    my $success = Read();

1.2.4. $boolean = Write($time);

Writes current BIND configuration.

Example 4. 

    my $success = Write();

1.2.5. @array = GetForwarders();

Returns list of general DNS forwarders.

Example 5. 

    my $list_of_forwarders = GetForwarders();

1.2.6. $boolean = AddForwarder($ipv4);

Adds a new forwarder into the list of current forwarders.

Example 6. 

    my $success = AddForwarder($forwarder_ip);

1.2.7. $boolean = RemoveForwarder($ipv4);

Removes forwarder from the list of current forwarders.

Example 7. 

    my $success = RemoveForwarder($forwarder_ip);

1.2.8. $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.

Example 8. 

    my $is_supported = IsLoggingSupported($forwarder_ip);

1.2.9. $hash = GetLoggingChannel();

Returns hash with current logging channel.

Example 9. 

  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'};
  }

1.2.10. $boolean = SetLoggingChannel($hash);

Returns hash with current logging channel.

Example 10. 

  if ($log_to_syslog) {
    $success = SetLoggingChannel(
      'destination' => 'syslog'
    );
  } else {
    $success = SetLoggingChannel(
      'destination' => 'file',
      'filename'    => '/var/log/named.log',
      'versions'    => '8',
      'size'        => '10M',
    );
  }

1.2.11. $array = GetLoggingCategories();

Returns list of used logging categories.

Example 11. 

  my $categories = GetLoggingCategories();
  foreach my $category (@{$categories}) {
    print "Using category: ".$category."\n";
  }

1.2.12. $boolean = SetLoggingCategories($array);

Returns list of used logging categories.

Example 12. 

  my @categories = ('default', 'xfer-in');
  my $success = SetLoggingCategories(\@categories);

1.2.13. $hash = GetACLs();

Returns hash of possible ACLs.

Example 13. 

  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";
    }
  }

1.2.14. $hash = GetZones($string);

Returns all DNS zones administered by this DNS server.

Example 14. 

  my $zones = GetZones();
  foreach my $zone (keys %{$zones}) {
    print
      "Zone Name: ".$zone." ".
      "Zone Type: ".$zones->{$zone}->{'type'}."\n"; # 'master' or 'slave'
  }

1.2.15. $array = GetZoneMasterServers($string);

Returns list of master servers assigned to this slave zone. Master zones do not have any master servers defined.

Example 15. 

  my $zone = 'example.org';
  foreach my $server @(GetZoneMasterServers($zone)) {
    print "Zone ".$zone." uses ".$server." master server\n";
  }

1.2.16. $boolean = SetZoneMasterServers($string,$array);

Sets masterservers for slave zone.

Example 16. 

  my @masterservers = ('192.168.32.1','192.168.32.2');
  my $zone = 'example.org';
  my $success = SetZoneMasterServers($zone, \@masterservers);

1.2.17. $boolean = AddZone($string,$string,$hash);

Function creates new DNS zone. Option 'masterserver' is needed for 'slave' zone.

Example 17. 

  # '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'
    }
  );

1.2.18. $boolean = RemoveZone($string);

Function removes a zone.

Example 18. 

    $success = RemoveZone('example.org');

1.2.19. $array = GetZoneTransportACLs($string);

Function returns list of ACLs used for Zone Transportation.

Example 19. 

  my $acls = GetZoneTransportACLs('example.org');
  foreach my $acl_name (@{$acls}) {
    print "ACL used: ".$acl_name."\n";
  }

1.2.20. $boolean = AddZoneTransportACL($string,$string);

Adds ACL into ACLs allowed for Zone Transportation. ACL must be known (default or custom).

Example 20. 

    my $success = AddZoneTransportACL('example.org','localnets');

1.2.21. $boolean = RemoveZoneTransportACL($string,$string);

Removes ACL from ACLs allowed for Zone Transportation. ACL must be known (default or custom).

Example 21. 

    my $success = RemoveZoneTransportACL('example.org','localnets');

1.2.22. $array = GetZoneNameServers($string);

Function returns list of Zone Name Servers. Only Zone base name servers are returned.

Example 22. 

    my $nameservers = GetZoneNameServers('example.org');

1.2.23. $array = GetZoneMailServers($string);

Function returns list of hashes of Zone Mail Servers. Only Zone base mail servers are returned.

Example 23. 

  my $mailservers = GetZoneMailServers('example.org');
  foreach my $mailserver (@{$mailservers}) {
    print
        "Mail Server: ".$mailserver->{'name'}." ".
        "Priority: ".$mailserver->{'priority'};
  }

1.2.24. $array = GetZoneRRs($string);

Returns list of hashes with all zone records inside. Base Zone Name and Mail Servers are filtered out.

Example 24. 

  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
  }

1.2.25. $boolean = AddZoneRR($string,$string,$string,$string);

Adds Zone Resource Record.

Example 25. 

  # 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
  );

1.2.26. $boolean = RemoveZoneRR($string,$string,$string,$string);

Removes Zone Resource Record.

Example 26. 

  # 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
  );

1.2.27. $boolean = AddZoneNameServer($zone,$nameserver);

Adds zone nameserver into the zone.

Example 27. 

  # 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.');

1.2.28. $boolean = RemoveZoneNameServer($zone,$nameserver);

Removes zone nameserver from the zone.

Example 28. 

  # 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.');

1.2.29. $boolean = AddZoneMailServer($zone,$mailserver,$priority);

Adds zone nameserver into the zone.

Example 29. 

  # 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);

1.2.30. $boolean = RemoveZoneMailServer($zone,$mailserver,$priority);

Removes zone mailserver from the zone.

Example 30. 

  # 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);

1.2.31. $hash = GetZoneSOA($zone);

Adds zone nameserver into the zone.

Example 31. 

  # 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";
  }

1.2.32. $hash = SetZoneSOA($zone, $soa);

Adds zone nameserver into the zone.

Example 32. 

  # 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);

1.2.33. $reversezone = GetReverseZoneNameForIP($hostname);

Returns reverse zone for IPv4 if such zone is administered by this DNS server.

Example 33. 

  my $reversezone = GetReverseZoneNameForIP('192.168.58.12');

1.2.34. $reverseip = GetReverseIPforIPv4($ipv4);

Returns reverse ip for IPv4.

Example 34. 

  my $reverseip = GetReverseIPforIPv4('192.168.58.12');
  -> '12.58.168.192.id-addr.arpa'

1.2.35. $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 35. 

  $success = AddHost('example.org','dhcp25','192.168.58.25');
  $success = AddHost('example.org','dhcp27.example.org.','192.168.58.27');

1.2.36. $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 36. 

  $success = RemoveHost('example.org','dhcp25.example.org.','192.168.58.25');
  $success = RemoveHost('example.org','dhcp27','192.168.58.27');

1.2.37. $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 37. 

  my $hosts = GetZoneHosts();
  foreach my $host (@{$hosts}) {
    print
      "zone: ".$host->{'zone'}." ".
      "hostname: ".$host->{'key'}." ".
      "ipv4: ".$host->{'value'};
  }