Информация на этой странице находится в доработке. Информация может добавляться и изменяться.
Инструкция по установке и первичной настройке #Bind9.
Исходные данные
- IP-адрес DNS-сервера
NS1: 192.168.1.2. - IP-адрес DNS-сервера
NS2: 192.168.1.3. - IP-адрес домена
example.org: 192.168.1.5. - IP-адрес домена
mail.example.org: 192.168.1.6.
Установка
1
| apt install --yes bind9
|
Настройка
- Настроить Bind9 на режим работы только с адресами IPv4:
1
| mv '/etc/default/named' '/etc/default/named.orig' && cp '/etc/default/named.orig' '/etc/default/named' && sed -i 's|-u bind|-u bind -4|g' '/etc/default/named'
|
- Сделать резервную копию файлов
named.conf.options и named.conf.root-hints:
1
| for i in 'named.conf.options' 'named.conf.root-hints'; do mv "/etc/bind/${i}" "/etc/bind/${i}.orig" && touch "/etc/bind/${i}"; done
|
- Привести файл
/etc/bind/named.conf.root-hints к следующему виду:
1
2
3
4
| view "default" {
match-clients { any; };
zone "." { type hint; file "/usr/share/dns/root.hints"; };
};
|
Authoritative Server
Настройка основного и вторичного авторитетных серверов имён.
Primary
- Привести файл
/etc/bind/named.conf.options к следующему виду:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| acl local { 127.0.0.0/8; };
acl dns-secondary { 192.168.1.3; };
options {
directory "/var/cache/bind";
listen-on { any; };
listen-on-v6 { none; };
recursion no;
allow-query { any; };
allow-query-cache { none; };
allow-transfer { dns-secondary; }
auth-nxdomain no;
dnssec-validation no;
qname-minimization off;
version none;
};
|
- Создать файл прямой зоны
/etc/bind/zone.example.org со следующим содержанием:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| $TTL 24h
$ORIGIN example.com.
; SOA
@ IN SOA ns1.example.com. postmaster.example.com. (
2025031500 ; Serial
10m ; Refresh
1h ; Retry
1w ; Expire
6m ) ; Negative Cache TTL
; NS
@ IN NS ns1.example.com.
@ IN NS ns2.example.com.
ns1 IN A 192.168.1.2
ns2 IN A 192.168.1.3
; MAIN
@ IN A 192.168.1.5
www IN CNAME @
; MAIL
@ IN MX 10 mail.example.com.
mail IN A 192.168.1.6
; TXT
@ IN TXT "v=spf1 a mx ~all"
_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:postmaster@example.com; ruf=mailto:postmaster@example.com; adkim=r; aspf=r"
dkim._domainkey IN TXT "v=DKIM1; p=TOKEN"
|
- Создать файл обратной зоны
/etc/bind/zone.example.org.rev со следующим содержанием:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| $TTL 24h
; SOA
@ IN SOA ns1.example.com. postmaster.example.com. (
2025031500 ; Serial
10m ; Refresh
1h ; Retry
1w ; Expire
6m ) ; Negative Cache TTL
; NS
@ IN NS ns1.example.com.
@ IN NS ns2.example.com.
2 IN PTR ns1.example.com.
3 IN PTR ns2.example.com.
; MAIN
5 IN PTR www.example.com.
6 IN PTR mail.example.com.
|
- Создать файл локальной зоны
/etc/bind/zone.example.org.local со следующим содержанием:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| $TTL 3h
$ORIGIN example.com.
; SOA
@ IN SOA ns1.example.com. postmaster.example.com. (
2025031500 ; Serial
10m ; Refresh
1h ; Retry
1w ; Expire
6m ) ; Negative Cache TTL
; NS
@ IN NS ns1.example.com.
ns1 IN A 127.0.0.1
; MAIN
@ IN A 127.0.0.1
; MAIL
@ IN MX 10 mail.example.com.
mail IN A 127.0.0.1
|
- Добавить в файл
/etc/bind/named.conf.local описание локальной, прямой и обратной зоны example.org:
1
2
3
4
5
6
7
8
9
10
| // view "local" {
// match-clients { local; };
// zone "example.com" { type primary; file "/etc/bind/zone.example.com.local"; };
// };
view "public" {
match-clients { any; };
zone "example.com" { type primary; file "/etc/bind/zone.example.com"; };
zone "1.168.192.in-addr.arpa" { type primary; file "/etc/bind/zone.example.com.rev"; };
};
|
Secondary
- Привести файл
/etc/bind/named.conf.options к следующему виду:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| acl local { 127.0.0.0/8; };
primaries dns-primary { 192.168.1.3; };
options {
directory "/var/cache/bind";
listen-on { any; };
listen-on-v6 { none; };
recursion no;
allow-query { any; };
allow-query-cache { none; };
auth-nxdomain no;
dnssec-validation no;
qname-minimization off;
version none;
};
|
- Добавить в файл
/etc/bind/named.conf.local описание локальной, прямой и обратной зоны example.org:
1
2
3
4
5
6
7
8
9
10
| // view "local" {
// match-clients { local; };
// zone "example.com" { type primary; file "/etc/bind/zone.example.com.local"; };
// };
view "public" {
match-clients { any; };
zone "example.com" { type secondary; file "zone.example.com"; primaries { dns-primary; }; };
zone "1.168.192.in-addr.arpa" { type secondary; file "zone.example.com.rev"; primaries { dns-primary; }; };
};
|
Resolver (Caching Name Servers)
Настройка резолвера в качестве кэширующего сервера имён.
- Привести файл
/etc/bind/named.conf.options к следующему виду:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| acl local { 127.0.0.0/8; };
acl trusted { 127.0.0.0/8; };
options {
directory "/var/cache/bind";
listen-on { any; };
listen-on-v6 { none; };
recursion yes;
allow-query { trusted; };
allow-query-cache { trusted; };
allow-recursion { trusted; };
allow-transfer { none; };
auth-nxdomain no;
empty-zones-enable yes;
dnssec-validation no;
qname-minimization off;
version none;
// forward only;
// forwarders { 8.8.8.8; 77.88.8.8; };
};
|