1.13 Шаг 9: Настройка динамического обновления DNS через Kerberos

1.13 Шаг 9: Настройка динамического обновления DNS через Kerberos

Samba has the capability to automatically update the bind zone files via Kerberos. While this step is optional, it is highly recommended. If you are using Samba’s internal DNS server, no configuration is needed, and you can skip this step.

Самба может динамически обновлять файл зоны через Kerberos. Этот шаг не является обязательным, но настоятельно рекомендован. Если вы используете внутренний DNS сервер Samba, то можете расслабиться и пропустить этот шаг. Eng.

To setup dynamic DNS updates you need to have a recent version of bind installed. It is highly recommended that you install at least version 9.8.0 as that version includes a set of patches from the Samba Team to make dynamic DNS updates much more robust and easier to configure. In the instructions below we give instructions for both bind 9.7.2 and 9.8.0, but please use 9.8.0 or later if at all possible.

Для настройки динамического обновления DNS установите последнюю версию bind. Настоятельно рекомендуем установить хотя бы версию 9.8.0, она включает в себя набор патчей от команды разработчиков Samba. Вам будет проще настроить обновление DNS, да и работать оно будет надежнее. Ниже описано как настроить динамическое обновление на версиях bind 9.7.2 и 9.8.0, но мы настоятельно рекомендуем использовать версию 9.8.0 и более поздние, если это возможно. Eng.

You can tell what version of bind you have using the command /usr/sbin/named -V. If your OS does not have bind-9.8.0 or later, then please consider getting it from a package provided by a 3rd party (for example, on Ubuntu there is a ppa available with the newer versions of bind).

Команда /usr/sbin/named -V подскажет используемую вами версию bind. В случае если в вашей системе нет bind-9.8.0 (или более свежей версии), то рассмотрите возможность подключения сторонних репозитариев для его установки (например в Ubuntu новые версии bind доступны через ppa (персональные архивы пакетов, прим. переводчика)). Eng.

1.13.1 Bind 9.8.0 или новее

When using bind-9.8.0 or later you need to add the following to the options section of your bind config:

Если вы используете bind-9.8.0 (или новее), тогда добавьте в секцию options файла конфигурации bind следующее: Eng.

 options {
  [...]
  tkey-gssapi-keytab "/usr/local/samba/private/dns.keytab";
  [...]
  };

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.

Обычно этот файл находится в директории /etc/bind, для уточнения его местоположения смотрите документацию на ваш дистрибутив. Eng.

1.13.2 Bind 9.7.x

If you have bind-9.7.x (specifically 9.7.2 or later), then first determine if you can at all possibly run bind-9.8. You will have far fewer problems. Otherwise, follow these instructions.

Если вы используете bind-9.7.x (а конкретно 9.7.2 и позднее), подумайте, можно ли его обновить до bind-9.8. Вы избавитесь от массы проблем, в противном случае действуйте по инструкции ниже. Eng.

The Samba provision will have created a custom /usr/local/samba/private/named.conf.update configuration file. You need to include this file in your master named.conf to allow Samba/Kerberos DNS updates to automatically take place. Be advised that if you include this file in Bind versions that don’t support it, Bind will fail to start.

На шаге настройки домена создастся файл конфигурации /usr/local/samba/private/named.conf.update. Нужно будет включить его в основной файл конфигурации named.conf, для того чтобы разрешить динамическое обновление DNS зон Samba с помощью Kerberos. Необходимо также учесть, что если эта возможность не поддерживается вашей версией bind, то он (bind) не запустится. Eng.

You additionally need to set two environment variables when using bind-9.7.x:

При использовании bind-9.7.x дополнительно потребуется установить две переменные среды: Eng.

  KEYTAB_FILE="/usr/local/samba/private/dns.keytab"
  KRB5_KTNAME="/usr/local/samba/private/dns.keytab"
  export KEYTAB_FILE
  export KRB5_KTNAME

These should be put in your settings file for bind. On Debian based systems (including Ubuntu) this is in /etc/default/bind9. On RedHat and SUSE derived systems it is in /etc/sysconfig/named, please refer to your distribution documentation for the correct location to set these environment variables. Strictly speaking you only either need KEYTAB_FILE or KRB5_KTNAME, but which you need depends on your distribution, The dns.keytab must be readable by the bind server process. Generally, this is accomplished by executing:

Их необходимо поместить в файл настройки bind. В Debian дистрибутивах (включая Ubuntu) — это /etc/default/bind9. В RedHat и SUSE — это /etc/sysconfig/named. Обратитесь к документации на дистрибутив для уточнения размещения этих переменных. Вообще требуется одна из них, KEYTAB_FILE или KRB5_KTNAME, это зависит от вашего дистрибутива, но проще установить обе. Файл dns.keytab должен быть доступен для чтения процессу bind. Обычно это достигается выполнением команды: Eng.

   $ chown named:named /usr/local/samba/private/dns.keytab

(the provision should have setup these permissions for you automatically).

(на шаге подготовки домена права должны были выставиться автоматически). Eng.

Finally, you need to add the following to the options section of your bind config:

В заключение добавьте следующие строки в раздел options файла конфигурации bind: Eng.

 options {
  [...]
  tkey-gssapi-credential "DNS/server.samdom.example.com";
  tkey-domain "SAMDOM.EXAMPLE.COM";
  [...]
  };

The last part of the credential in the first line must match the dns name of the server you have set up. 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.

В первой строке укажите DNS имя сервера, на который вы устанавливаете Samba. Обычно этот файл находится в папке /etc/bind. Точнее — в документации на дистрибутив. Eng.


1.13.3 Тестирование и отладка динамического обновления DNS

The way the automatic DNS update in Samba works is that the provision will create a file /usr/local/samba/private/dns_update_list, which contains a list of DNS entries that Samba will try to dynamically update at startup and every 10 minutes thereafter using samba_dnsupdate utility. Updates will only happen if the DNS entries do not already exist. Remember that you need nsupdate utility from bind the distribution for all these to work.

В процессе настройки домена создастся файл /usr/local/samba/private/dns_update_list, содержащий список DNS записей, требующих динамического обновления. Samba будет пытаться обновлять этот список при запуске и каждые 10 минут с помощью утилиты samba_dnsupdate. Добавляются только новые, несуществующие DNS записи. Обратите внимание, для этого потребуется утилита nsupdate из дистрибутива bind. Eng.

If you want to test or debug this process, then please run this as root:

Для отладки или проверки работоспособности утилиты, запустите команду от root: Eng.

 /usr/local/samba/sbin/samba_dnsupdate --verbose --all-names

The command line options specified will force an update of all records in the dns_update_list, as well as output detailed information on what is being done.

Эта команда вызовет обновление всех записей списка dns_update_list и вернет на консоль дополнительную отладочную информацию. Eng.

1.13.4 Взаимодействие с Apparmor или SELinux

If you are using Apparmor or SELinux, you have to ensure that the bind process has read access to the /usr/local/samba/private/dns.keytab file, the /usr/local/samba/private/named.conf file as well as read-write access to the /usr/local/samba/private/dns directory and it’s own zone file. The Samba provision tries to setup the permissions correctly for these files, but you may find you need to make changes in your Apparmor or SELinux configuration if you are running either of those. If you are using Apparmor then the aa-logprof command may help you add any missing permissions you need to add after you start Samba and bind for the first time after configuring them.

Если вы используете профили Apparmor или SELinux, то убедитесь что процесс bind имеет доступ на чтение к файлам /usr/local/samba/private/dns.keytab, /usr/local/samba/private/named.conf, а также доступ на чтение/запись к директории /usr/local/samba/private/dns и является владельцем файла зоны. На этапе подготовки домена Samba пытается корректно установить права доступа к этим файлам и папкам, но возможно вам придется изменить таже и настройки профилей Apparmor или SELinux, конечно если вы их используете. При использовании профилей Apparmor, запустите команду aa-logprof. Вы получите подсказку о том какие разрешения нужно добавить, после запуска и первичной настройки Samba и bind. Eng.

Please refer to Step 11: Permissions, SELinux Labeling and Policy for more information.

Пожалуйста ознакомьтесь с Шаг 11: «Разрешения, метки и политики SELinux» для получения дополнительной информации. Eng.