1.11 Шаг 7: Настройка DNS

1.11 Шаг 7: Настройка DNS

A working DNS setup is essential to the correct operation of Samba. Without the right DNS entries, Kerberos won’t work, which in turn means that many of the basic features of Samba won’t work.

Настройка рабочего DNS сервера влияет на корректность работы Samba. Без правильных записей в DNS не будет работать Kerberos, и в результате окажутся неработоспособны базовые возможности Samba. Eng.

It is worth spending some extra time to ensure your DNS setup is correct, as debugging problems caused by mis-configured DNS can take a lot of time later on.

Неправильная настройка DNS может в дальнейшем отнять у вас много времени на отладку, поэтому стоит потратить немного времени и корректно настроить ваш DNS сервер. Eng.

1.11.1 DNS сервер

1.11.1.1 Внутрениий DNS сервер Samba

If you specified --dns-backend=SAMBA_INTERNAL or did not specify any backend at all when you provisioned, there is no further setup required for the DNS server. However, you still need to configure your /etc/resolv.conf as shown in Configure /etc/resolv.conf

Вам не понадобится настраивать DNS сервер в дальнейшем, если при подготовке Samba в качестве основного контроллера домена вы использовали ключ --dns-backend=SAMBA_INTERNAL или не указывали этот ключ вообще. Однако придется настроить ваш файл /etc/resolv.conf как это описано в 1.11.2 Настройка файла /etc/resolv.conf. Eng.

If you want the internal DNS server to forward requests it isn’t responsible for, then add the following to your smb.conf:

Для пересылки запросов не относящихся к зоне ответственности вашего DNS сервера добавьте следующую строку в ваш конфигурационный файл smb.conf: Eng.

  dns forwarder = {IP-Address of the DNS you want to forward to}

Warning: If you are running X windows on your machine, networkmanager could be spawning dnsmasq, check the logs for lines like:

Внимание: Если на вашем компьютере запущен X windows сервер, networkmanager для DNS запросов будет использовать dnsmasq. Проверьте ваш лог файл на наличие строки вида: Eng.

 Failed to bind to 0.0.0.0:53 TCP - NT_STATUS_ADDRESS_ALREADY_ASSOCIATED

If you need to disable this you can open /etc/NetworkManager/NetworkManager.conf in your favorite editor as root, and comment out the line dns=dnsmasq, then restart network-manager

Откройте в вашем любимом текстовом редакторе конфигурационный файл /etc/NetworkManager/NetworkManager.conf с правами root, закомментируйте строку dns=dnsmasq, после этого перезапустите сеть командой restart network-manager Eng.

1.11.1.2 Bind 9.8.0 or newer

If using BIND, the next step to get a working DNS setup for Samba is to start with the DNS configuration file that is created by the provision step or if you are using any of the other samba-tool options (classicupgrade for example) you can specify —dns-backend=BIND9_DLZ or —dns-backend=BIND9_FLATFILE.

Вы решили использовать Bind в роли DNS сервера Samba. В этом случае на шаге подготовки домена нужно было использовать ключи —dns-backend=BIND9_DLZ или —dns-backend=BIND9_FLATFILE. Это также касается случая использования других утилит Samba (команда samba-tool), например classicupgrade. Eng.

You can activate the configuration that the provision has created by including this configuration file in bind’s named configuration file. This file is typically located in the /etc/bind directory, please refer to your distribution documentation for the location of this file on your system. Once located, add the following line to the configuration file:

На шаге подготовки домена будет создан конфигурационный файл named.conf, включите его в ваш основной конфигурационный файл Bind. По умолчанию файл конфигурации Bind находится в директории /etc/bind. Посмотрите документацию к вашей операционной системе на предмет распольжения этого файла. Добавьте в него следующую строку: Eng.

 include "/usr/local/samba/private/named.conf";

Edit that file to uncomment the correct dlz plugin line, based on your version of bind. Open the /usr/local/samba/private/named.conf file in a text editor and follow the instructions inside.

Также необходимо раскомментировать в файле конфигурации строку dlz плагина для вашей версии Bind (прим. переводчика: dlz — динамически загружаемая зона). Следуйте инструкциям в файле /usr/local/samba/private/named.conf. Eng.

After adding that line you should restart your Bind server and check in the system logs for any problems. If available, you can run named-checkconf to help you fix any problems with your named configuration.

После добавления строки перезагрузите сервер Bind и проверьте системный лог на ошибки. При обнаружении ошибок запустите программу диагностики вашей конвигурации Bind named-checkconf. Eng.

1.11.1.3 Bind 9.7.x

Users of bind-9.7.x are strongly encouraged to upgrade to bind-9.8 or bind-9.9. If this is not possible, refer to the section Configure Kerberos DNS Dynamic Updates for instructions on configuring bind-9.7.

Мы очень не рекомендуем использовать bind-9.7.x, по возможности необходимо перейти на версии bind-9.8 или bind-9.9. Если же это невозможно, тогда изучите раздел 1.13 Шаг 9: Настройка динамического обновления DNS через Kerberos для получения инструкций по настройке bind-9.7. Eng.

1.11.1.4 Bind (Все версии)

A common problem you may encounter is that many modern Linux distributions activate ‘Apparmor’ or ‘SELinux’ by default, and these may be configured to deny access to Bind for your the named.conf and zone files created in the provision. If your Bind logs show that Bind is getting a access denied error accessing these files, please see your local system documentation for how to enable access to these files in Bind (hint: for Apparmor systems such as Ubuntu, the command aa-logprof may be useful).

В большинстве современных дистрибутивов Linux по умолчанию активированы политика безопасности ‘Apparmor’ или усиленная защита ‘SELinux’. Может быть запрещено изменение файла named.conf и создание файла зоны на шаге подготовки домена. Если в лог файле Bind сервера вы обнаружили ошибки доступа к файлам Bind, то изучите документацию на вашу операционную систему на предмет открытия доступа к этим файлам Bind (подсказка: в системах с Apparmor, таких как Ubuntu, попробуйте использовать команду aa-logprof ). Eng.

*Note: On Debian systems, the zone auto-generation might detect and use 127.0.1.1 as the domain controller’s IP address. This will cause problems when trying to connect to the server from client machines. To fix this, you will need to adjust /usr/local/samba/private/named.conf by changing 127.0.1.1 to reflect the actual IP address of the server you’re setting up.
*Note: On Debian SID (bind9 package), /etc/bind/named.conf.options is missing and this will cause the named daemon to fail to start. To fix this either create an empty file, or comment out corresponding line in /etc/bind/named.conf. See your syslog messages for more information.

*Замечание: В Debian дистрибутивах автоматически создаваемая зона может использовать адрес 127.0.1.1 в качестве IP адреса контроллера домена. Это вызовет проблему при подключении с клиентских компьютеров. Исправьте в файле /usr/local/samba/private/named.conf 127.0.1.1 на реальный IP адрес вашего сервера.
*Замечание: В нестабильных версиях Debian (пакет bind9) отсутствует файл /etc/bind/named.conf.options и это может привести к ошибке запуска Bind. Можно создать пустой файл или закоментировать соответствующую строку в файле /etc/bind/named.conf. Для дополнительной информации смотрите ваш syslog файл. Eng.

1.11.2 Настройка файла /etc/resolv.conf

For all the local DNS lookups to resolve correctly, we need to modify the server’s /etc/resolv.conf file. The following example should be sufficient to have DNS resolve properly:

Для корректного распознавания всех локальных DNS запросов необходимо изменить файл /etc/resolv.conf. Ниже приведен пример рабочего файла: Eng.

 domain samdom.example.com
 nameserver 192.168.1.2

*Note: Remember to change the IP Address to your Samba server’s IP Address
*Note: If your server is set up to receive its IP configuration via DHCP, the /etc/resolv.conf file might be automatically updated. Refer to your distribution’s documentation on how to stop this behavior.

*Замечание: Не забудьте исправить IP адрес на адрес вашего сервера Samba.
*Замечание: Если ваш сервер получает IP адрес динамически по DHCP, то файл /etc/resolv.conf может изменяться автоматически. Отключите эту возможность, изучив документацию на ваш дистрибутив. Eng.

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

To test that DNS is working properly, run the following commands and compare the output to what is shown:

Для проверки корректности работы DNS выполните команды указанные ниже и сравните результаты их выполнения: Eng.

 $ host -t SRV _ldap._tcp.samdom.example.com.
 _ldap._tcp.samdom.example.com has SRV record 0 100 389 samba.samdom.example.com.
 $ host -t SRV _kerberos._udp.samdom.example.com.
 _kerberos._udp.samdom.example.com has SRV record 0 100 88 samba.samdom.example.com.
 $ host -t A samba.samdom.example.com.
 samba.samdom.example.com has address 10.0.0.1

The answers you get should be similar to the ones above (adjusted for your DNS domain name and hostname). If you get any errors, carefully check your system logs to locate the problem.

Результаты должны быть похожи на те, что показаны выше (за исключением вашего домена и имени сервера). В случае возникновения ошибок, тщательно изучите системный лог файл. Eng.