7. YaPI::DNSD

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

7.1. List of Global Functions

7.2. Functions

7.2.1. $status = StopDnsService($config);

Immediatelly stops the DNS service. Returns nonzero if operation succeeded, zero if operation failed.

Example 91. 

  my $status = StopDnsService ({});
  if ($status == 0)
  {
    print "Stopping DNS server failed";
  }
  else
  {
    print "Stopping DNS server succeeded";
  }

7.2.2. $status = StartDnsService ($config);

Immediatelly starts the DNS service. Returns nonzero if operation succeeded, zero if operation failed.

Example 92. 

  my $status = StartDnsService ({});
  if ($status == 0)
  {
    print "Starting DNS server failed";
  }
  else
  {
    print "Starting DNS server succeeded";
  }

7.2.3. $status = GetDnsServiceStatus ($config);

Check if DNS service is running. Returns nonzero if service is running, zero otherwise.

Example 93. 

  my $status = GetDnsServiceStatus ({});
  if ($status == 0)
  {
    print "DNS server is not running";
  }
  else
  {
    print "DNS server is running";
  }

7.2.4. $options = ReadGlobalOptions ($config);

Reads all global options of the DNS server.

Example 94. 

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

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

Example 95. 

  my $options = [
    {
      "key" => "dump-file",
      "value" => "\"/var/log/named_dump.db\"",
    },
    {
      "key" => "statistics-file",
      "value" => "\"/var/log/named.stats\"",
    },
  ]
  $success = WriteGlobalOptions ({}, $options);

7.2.6. $zones = ReadZones ($config);

Reads all zones of the DNS server.

Example 96. 

  my $zones = ReadZones ({});
  if (! defined ($zones))
  {
    print ("Could not read zones");
  }
  else
  {
    my $count = @{$zones};
    print "Maintaining $count zones";
  }

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

Example 97. 

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