Настройка Сравнение версий

Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

Следующая версия
Предыдущая версия
wiki:руководство_по_ubuntu_server:служба_доменных_имен:configuration [2012/06/15 11:00]
создано
wiki:руководство_по_ubuntu_server:служба_доменных_имен:configuration [2017/03/28 15:46] (текущий)
[Первичный мастер]
Строка 8: Строка 8:
 =====Настройка===== =====Настройка=====
  
-There are many ways to configure ​BIND9. ​Some of the most common configurations are a caching nameserverprimary master, and as a secondary master.+Существует много способов настроить ​BIND9. ​Наиболее распространенные конфигурации - это кэширующий сервер именпервичный мастер и вторичный мастер.
  
-    When configured as a caching nameserver ​BIND9 will find the answer to name queries and remember the answer when the domain is queried again.+  -- Когда ​BIND9 настроен как кэширующий сервер,​ он ищет ответы на запросы имени и запоминает ответ на случай,​ если запрос придет повторно. 
 +  -- В качестве первичного мастера BIND9 читает данные зоны из локального файла и является ответственным за эту зону. 
 +  -- В качестве вторичного мастера BIND9 получает данные по зоне (целиком) с другого сервера имен, отвечающего за эту зону.
  
-    As a primary master server BIND9 reads the data for a zone from a file on it's host and is authoritative for that zone.+====Обзор====
  
-    In a secondary master configuration BIND9 gets the zone data from another nameserver authoritative for the zone.+Файлы настройки DNS сохраняются в каталоге /etc/bind. Основной файл конфигурации - это /​etc/​bind/​named.conf.
  
-    Overview +Строки **include** определяют имена файлов,​ которые содержат DNS опции. Строка **directory** в файле /​etc/​bind/​named.conf.options говорит DNS где искать файлы. Все файлы, используемые BIND, будут относительными к этому каталогу.
-    Caching Nameserver +
-    Primary Master +
-    Secondary Master+
  
-====Обзор====+Файл с именем /​etc/​bind/​db.root описывает корневые сервера имен в мире. Сервера со временем меняются,​ поэтому файл /​etc/​bind/​db.root должен обслуживаться сейчас и потом. ​Обычно это происходит в качестве обновления к пакету **bind9**. Секция **zone** определяет мастер сервер и она сохранена в файле, определяемой опцией **file**.
  
-The DNS configuration files are stored in the /etc/bind directoryThe primary configuration file is /​etc/​bind/​named.conf.+Существует возможность настроить один сервер как кэширующий сервер имен, первичный мастер и вторичный мастер одновременноСервер может быть началом авторизации (SOA) для одной зоны, при этом предоставляя вторичный сервис для другойИ при всем этом предоставлять кэширующий сервис в локальной сети (LAN).
  
-The include line specifies the filename which contains the DNS options. The directory line in the /​etc/​bind/​named.conf.options file tells DNS where to look for files. All files BIND uses will be relative to this directory. 
- 
-The file named /​etc/​bind/​db.root describes the root nameservers in the world. The servers change over time, so the /​etc/​bind/​db.root file must be maintained now and then. This is usually done as updates to the bind9 package. The zone section defines a master server, and it is stored in a file mentioned in the file option. 
- 
-It is possible to configure the same server to be a caching name server, primary master, and secondary master. A server can be the Start of Authority (SOA) for one zone, while providing secondary service for another zone. All the while providing caching services for hosts on the local LAN. 
  
 ====Кэширующий сервер имен==== ====Кэширующий сервер имен====
  
-The default configuration is setup to act as a caching serverAll that is required is simply adding the IP Addresses of your ISP'​s ​DNS serversSimply uncomment and edit the following in /​etc/​bind/​named.conf.options:​ +По умолчанию конфигурация настраивается на работу кэширующим серверомВсе что для этого требуется - это добавить ​IP адреса ​DNS серверов вашего интернет провайдераПросто раскомментируйте и исправьте следующее в /​etc/​bind/​named.conf.options:​ 
 +<​code>​
 forwarders { forwarders {
                 1.2.3.4;                 1.2.3.4;
                 5.6.7.8;                 5.6.7.8;
            };            };
 +</​code>​
 +<​note>​Замените **1.2.3.4** и **5.6.7.8** на актуальные IP адреса серверов имен.</​note>​
 +Теперь перегружаем DNS сервер для применения новой конфигурации. Наберите в терминале:​
 +<​code>​sudo service bind9 restart</​code>​
  
-Replace 1.2.3.4 and 5.6.7.8 with the IP Adresses of actual nameservers. +Смотрите [[wiki:руководство_по_ubuntu_server:​служба_доменных_имен:​troubleshooting#​dig|dig]] для информации по тестированию кэширующего ​DNS сервера.
- +
-Now restart the DNS server, to enable the new configuration. From a terminal prompt: +
- +
-sudo service bind9 restart +
- +
-See dig for information on testing a caching ​DNS server.+
  
 ====Первичный мастер==== ====Первичный мастер====
  
-In this section ​BIND9 will be configured as the Primary Master for the domain ​example.com. ​Simply replace ​example.com ​with your FQDN (Fully Qualified Domain Name).+В этом разделе ​BIND9 будет настроен как первичный мастер для домена ​example.com. ​Просто замените ​example.com ​на ваше ​FQDN (квалифицированное имя домена).
  
 ===Файл прямой зоны=== ===Файл прямой зоны===
  
-To add a DNS zone to BIND9, ​turning BIND9 into a Primary Master serverthe first step is to edit /​etc/​bind/​named.conf.local:​ +Для добавления ​DNS зоны в BIND9, ​что превратит его в сервер первичного мастерапервым шагом отредактируем ​/​etc/​bind/​named.conf.local:​ 
 +<​code>​
 zone "​example.com"​ { zone "​example.com"​ {
  type master;  type master;
         file "/​etc/​bind/​db.example.com";​         file "/​etc/​bind/​db.example.com";​
 }; };
 +</​code>​
  
-Now use an existing zone file as a template to create the /​etc/​bind/​db.example.com ​file+Теперь используем существующий файл зоны в качестве шаблона для создания файла ​/​etc/​bind/​db.example.com:​ 
- +<​code>​sudo cp /​etc/​bind/​db.local /​etc/​bind/​db.example.com</code>
-sudo cp /​etc/​bind/​db.local /​etc/​bind/​db.example.com +
- +
-Edit the new zone file /etc/​bind/​db.example.com change localhost. to the FQDN of your server, leaving the additional "​."​ at the end. Change 127.0.0.1 to the nameserver'​s IP Address and root.localhost to a valid email address, but with a "​."​ instead of the usual "​@"​ symbol, again leaving the "​."​ at the end. Change the comment to indicate the domain that this file is for.+
  
-Create an A record for the base domain, ​example.com. ​Alsocreate an A record for ns.example.comthe name server in this example:+Редактируем новый файл зоны /​etc/​bind/​db.example.com, заменив localhostна FQDN нашего сервераоставляя дополнительную %%"."%% в концеЗаменим 127.0.0.1 на IP адрес сервера имен и root.localhost на правильный адрес emailно с %%"​."​%% вместо символа %%"​@"​%%,​ опять же оставляя %%"​."​%% на конце. Замените комментарии для указания домена,​ для которого этот файл сделан.
  
 +Создайте A запись для базового домена example.com. Также создайте A запись для ns.example.com - сервера имен в данном примере:​
 +<​code>​
 ; ;
 ; BIND data file for example.com ; BIND data file for example.com
Строка 79: Строка 71:
                         2419200 ​        ; Expire                         2419200 ​        ; Expire
                          ​604800 )       ; Negative Cache TTL                          ​604800 )       ; Negative Cache TTL
-        IN      A       ​192.168.1.10 
 ; ;
 @       ​IN ​     NS      ns.example.com. @       ​IN ​     NS      ns.example.com.
Строка 85: Строка 76:
 @       ​IN ​     AAAA    ::1 @       ​IN ​     AAAA    ::1
 ns      IN      A       ​192.168.1.10 ns      IN      A       ​192.168.1.10
 +</​code>​
  
-You must increment the Serial Number ​every time you make changes to the zone fileIf you make multiple changes before restarting BIND9simply increment the Serial ​once.+Вы должны увеличивать **Serial Number** каждый раз, как делаете изменения в файле зоныЕсли вы делаете множественные измененияпросто увеличьте ​Serial ​на единицу один раз перед перезапуском BIND9.
  
-Now, you can add DNS records to the bottom of the zone fileSee Common Record Types for details.+Теперь вы можете добавлять ​DNS записи в конец файла зоныСмотрите детали в разделе [[wiki:​руководство_по_ubuntu_server:​служба_доменных_имен:​references#​общие_типы_записей|Общие типы записей]].
  
-Many admins like to use the last date edited as the serial of a zone, such as 2012010100 ​which is yyyymmddss (where ss is the Serial Number)+<​note>​Многие администраторы предпочитают использовать дату последнего редактирования в качестве Serial зоны в виде ​2012010100, что соответствует формату ​yyyymmddss (где ​ss Serial Number ​[за день]).</​note>​
  
-Once you have made changes to the zone file BIND9 needs to be restarted for the changes to take effect+Как только вы произвели изменения в файле зоны, требуется перегрузить ​BIND9 для применения изменений
- +<​code>​sudo service bind9 restart</​code>​
-sudo service bind9 restart+
  
 ===Файл обратной зоны=== ===Файл обратной зоны===
  
-Now that the zone is setup and resolving names to IP Adresses a Reverse zone is also requiredA Reverse zone allows ​DNS to resolve an address to a name. +Теперь,​ поскольку зона создана и разрешает имена в IP адреса,​ требуется создать также обратную зонуОбратная зона позволяет ​DNS определять имя по IP адресу.
- +
-Edit /​etc/​bind/​named.conf.local and add the following:+
  
 +Редактируем /​etc/​bind/​named.conf.local и добавляем следующее:​
 +<​code>​
 zone "​1.168.192.in-addr.arpa"​ { zone "​1.168.192.in-addr.arpa"​ {
         type master;         type master;
         file "/​etc/​bind/​db.192";​         file "/​etc/​bind/​db.192";​
 }; };
 +</​code>​
  
-Replace ​1.168.192 ​with the first three octets of whatever network you are usingAlso, name the zone file /​etc/​bind/​db.192 ​appropriatelyIt should match the first octet of your network. +<​note>​Замените ​1.168.192 ​на первые три октета адресов сети, которую вы используетеТакже соответственно назовите файл зоны ​/​etc/​bind/​db.192. ​В нем должен совпадать первый октет вашей сети.</note>
- +
-Now create the /etc/​bind/​db.192 file: +
- +
-sudo cp /​etc/​bind/​db.127 /​etc/​bind/​db.192+
  
-Next edit /​etc/​bind/​db.192 ​changing the basically the same options as /​etc/​bind/​db.example.com:+Теперь создаем файл ​/​etc/​bind/​db.192
 +<​code>​sudo cp /​etc/​bind/​db.127 /​etc/​bind/​db.192</​code>​
  
 +Далее редактируем /​etc/​bind/​db.192,​ изменяя в основном те же опции, что и в /​etc/​bind/​db.example.com:​
 +<​code>​
 ; ;
 ; BIND reverse data file for local 192.168.1.XXX net ; BIND reverse data file for local 192.168.1.XXX net
Строка 128: Строка 119:
 @       ​IN ​     NS      ns. @       ​IN ​     NS      ns.
 10      IN      PTR     ​ns.example.com. 10      IN      PTR     ​ns.example.com.
 +</​code>​
  
-The Serial Number ​in the Reverse zone needs to be incremented on each change as wellFor each record you configure in /​etc/​bind/​db.example.com, ​that is for a different address, you need to create a PTR record in /​etc/​bind/​db.192.+Serial Number ​в обратной зоне также требуется увеличивать при каждом измененииДля каждой ​записи,​ которую вы настроите в /​etc/​bind/​db.example.com ​на другой адресвы должны создать запись ​PTR в /​etc/​bind/​db.192.
  
-After creating the reverse zone file restart ​BIND9: +После создания файла обратной зоны перегрузите ​BIND9: 
- +<​code>​sudo service bind9 restart</​code>​
-sudo service bind9 restart+
  
 ====Вторичный мастер==== ====Вторичный мастер====
  
-Once a Primary Master has been configured a Secondary Master is needed in order to maintain the availability of the domain should the Primary become unavailable. +Поскольку первичный мастер настроентребуется вторичный мастер для тогочтобы поддерживать домен при недоступности первичного мастера.
- +
-Firston the Primary Master serverthe zone transfer needs to be allowed. Add the allow-transfer option to the example Forward and Reverse zone definitions in /​etc/​bind/​named.conf.local:+
  
 +Для начала на первичном мастере надо разрешить передачу зоны. Добавьте опцию allow-transfer к определениям прямой и обратной зон в /​etc/​bind/​named.conf.local:​
 +<​code>​
 zone "​example.com"​ { zone "​example.com"​ {
         type master;         type master;
Строка 152: Строка 143:
  allow-transfer { 192.168.1.11;​ };  allow-transfer { 192.168.1.11;​ };
 }; };
 +</​code>​
 +<​note>​Замените 192.168.1.11 на IP адрес вашего вторичного сервера имен.</​note>​
  
-Replace 192.168.1.11 with the IP Address of your Secondary nameserver. +Перезапустим ​BIND9 на первичном мастере
- +<​code>​sudo service bind9 restart</code>
-Restart ​BIND9 on the Primary Master+
- +
-sudo service bind9 restart +
- +
-Next, on the Secondary Master, install the bind9 package the same way as on the Primary. Then edit the /etc/​bind/​named.conf.local and add the following declarations for the Forward and Reverse zones:+
  
 +Далее, на вторичном мастере установите пакет bind9 так же, как делали на первичном. Затем отредактируем /​etc/​bind/​named.conf.local и добавим следующие определения к прямой и обратной зонам:
 +<​code>​
 zone "​example.com"​ { zone "​example.com"​ {
  type slave;  type slave;
Строка 172: Строка 162:
         masters { 192.168.1.10;​ };         masters { 192.168.1.10;​ };
 }; };
 +</​code>​
 +<​note>​Замените 192.168.1.10 на IP адрес вашего первичного сервера имен.</​note>​
  
-Replace 192.168.1.10 with the IP Address of your Primary nameserver. +Перегружаем ​BIND9 на вторичном мастере
- +<​code>​sudo service bind9 restart</code>
-Restart ​BIND9 on the Secondary Master+
- +
-sudo service bind9 restart +
- +
-In /var/​log/​syslog you should see something similar to (some lines have been split to fit the format of this document):+
  
 +В /​var/​log/​syslog вы сможете увидеть нечто похожее на (некоторые строки разделены для соответствия формату документа):​
 +<​code>​
 client 192.168.1.10#​39448:​ received notify for zone '​1.168.192.in-addr.arpa'​ client 192.168.1.10#​39448:​ received notify for zone '​1.168.192.in-addr.arpa'​
 zone 1.168.192.in-addr.arpa/​IN:​ Transfer started. zone 1.168.192.in-addr.arpa/​IN:​ Transfer started.
Строка 197: Строка 186:
 transfer of '​example.com/​IN'​ from 192.168.1.10#​53:​ Transfer completed: 1 messages, ​ transfer of '​example.com/​IN'​ from 192.168.1.10#​53:​ Transfer completed: 1 messages, ​
 8 records, 225 bytes, 0.002 secs (112500 bytes/sec) 8 records, 225 bytes, 0.002 secs (112500 bytes/sec)
- +</​code>​ 
-Note: A zone is only transferred if the Serial Number ​on the Primary is larger than the one on the SecondaryIf you want to have your Primary Master ​DNS notifying Secondary ​DNS Servers of zone changesyou can add also-notify { ipaddress; }; in to /​etc/​bind/​named.conf.local ​as shown in the example below+<​note>​Обратите внимание,​ что передача зоны произойдет только если ​Serial Number ​на первичном сервере больше значения на вторичномЕсли вы хотите,​ чтобы первичный мастер ​DNS сообщал вторичному ​DNS серверу об изменении зонывы можете добавить **also-notify { ipaddress; };** в /​etc/​bind/​named.conf.local ​как показано в примере ниже
 +<​code>​
 zone "​example.com"​ { zone "​example.com"​ {
  type master;  type master;
Строка 213: Строка 202:
  also-notify { 192.168.1.11;​ };   also-notify { 192.168.1.11;​ }; 
  };  };
- +</​code></​note>​
  
-The default directory for non-authoritative zone files is /​var/​cache/​bind/​. ​This directory is also configured in AppArmor ​to allow the named daemon to write to itFor more information on AppArmor ​see AppArmor.+<​note>​Каталог по умолчанию для файлов неавторизованных зон ​- /​var/​cache/​bind/​. ​Этот каталог также настроен в **AppArmor** для разрешения доступа сервису **named** на запись в негоДля дополнительной информации по AppArmor ​смотрите [[wiki:​руководство_по_ubuntu_server:​безопасность:​apparmor|AppArmor]]</​note>​
  
 ---- ----