Это старая версия документа.


Решение проблем

Этот раздел посвящен способам определения причины проблем, возникающих с DNS и BIND9.

Тестирование

resolv.conf

Первый шаг в тестировании BIND9 это добавление IP адреса сервера имен в список определителей сетевых имен. Первичный сервер имен должен настраиваться, как и любой другой узел сети, с двойной проверкой. Просто отредактируйте /etc/resolv.conf, добавив следующее:

nameserver	192.168.1.10
nameserver	192.168.1.11
Вам надо добавить также IP адрес вторичного сервера имен на случай недоступности первичного.

dig

Если вы установили пакет dnsutils, вы можете проверить свою установку используя обзорную утилиту DNS dig:

1. После установки BIND9 примените dig к интерфейсу обратной петли (loopback), чтобы убедиться, что порт 53 прослушивается. Из терминала наберите:

dig -x 127.0.0.1

Вы должны увидеть строки вывода, похожие на следующее:

;; Query time: 1 msec
;; SERVER: 192.168.1.10#53(192.168.1.10)

2. Если BIND9 настроен у вас как кэширующий сервер, используйте dig для замера времени при разрешении имени внешнего домена:

dig ubuntu.com

Обратите внимание на время в конце вывода результата команды:

;; Query time: 49 msec

После повторного вызова dig должно произойти улучшение:

;; Query time: 1 msec

ping

Теперь для демонстрации как приложения могут использовать DNS для разрешения сетевых имен используйте утилиту ping для отправки ICMP эхо-запроса. Из терминала наберите следующее:

ping example.com

Это проверит может ли сервер имен разрешить имя ns.example.com в IP адрес. Вывод команды будет напоминать следующее:

PING ns.example.com (192.168.1.10) 56(84) bytes of data.
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.800 ms
64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.813 ms

named-checkzone

A great way to test your zone files is by using the named-checkzone utility installed with the bind9 package. This utility allows you to make sure the configuration is correct before restarting BIND9 and making the changes live.

  To test our example Forward zone file enter the following from a command prompt:
  named-checkzone example.com /etc/bind/db.example.com
  If everything is configured correctly you should see output similar to:
  zone example.com/IN: loaded serial 6
  OK
  Similarly, to test the Reverse zone file enter the following:
  named-checkzone 1.168.192.in-addr.arpa /etc/bind/db.192
  The output should be similar to:
  zone 1.168.192.in-addr.arpa/IN: loaded serial 3
  OK

The Serial Number of your zone file will probably be different.

Журналирование

BIND9 has a wide variety of logging configuration options available. There are two main options. The channel option configures where logs go, and the category option determines what information to log.

If no logging option is configured the default option is:

logging {

   category default { default_syslog; default_debug; };
   category unmatched { null; };

};

This section covers configuring BIND9 to send debug messages related to DNS queries to a separate file.

  First, we need to configure a channel to specify which file to send the messages to. Edit /etc/bind/named.conf.local and add the following:
  logging {
      channel query.log {      
          file "/var/log/query.log";
          severity debug 3; 
      }; 
  };
  Next, configure a category to send all DNS queries to the query file:
  logging {
      channel query.log {      
          file "/var/log/query.log"; 
          severity debug 3; 
      }; 
      category queries { query.log; }; 
  };

Note: the debug option can be set from 1 to 3. If a level isn't specified level 1 is the default.

  Since the named daemon runs as the bind user the /var/log/query.log file must be created and the ownership changed:
  sudo touch /var/log/query.log
  sudo chown bind /var/log/query.log
  Before named daemon can write to the new log file the AppArmor profile must be updated. First, edit /etc/apparmor.d/usr.sbin.named and add:
  /var/log/query.log w,
  Next, reload the profile:
  cat /etc/apparmor.d/usr.sbin.named | sudo apparmor_parser -r
  For more information on AppArmor see AppArmor
  Now restart BIND9 for the changes to take effect:
  sudo service bind9 restart

You should see the file /var/log/query.log fill with query information. This is a simple example of the BIND9 logging options. For coverage of advanced options see More Information.