Bind9 в режиме forwarding в Debian Squeeze
Както давным-давно я настраивал аналогичный сервис в OpenBSD. По аналогии той статьи только что настроил bind в Debian.
Ничего сверхестесственного делать ненужно 🙂
Сначала просто ставим bind9 штатным средством apt
root@gw > apt-get install bind9
Потом редактируем 2 конфига. Файлик номер один приводим к такому виду:
root@gw > vim /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0s placeholder.
allow-query { clients; };
allow-recursion { clients; };
forward only;
forwarders {
194.183.162.193;
194.183.162.130;
};
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { none; };
version "";
listen-on { 192.168.240.1; 127.0.0.1; };
};
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0s placeholder.
allow-query { clients; };
allow-recursion { clients; };
forward only;
forwarders {
194.183.162.193;
194.183.162.130;
};
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { none; };
version "";
listen-on { 192.168.240.1; 127.0.0.1; };
};
А в файлик номер два, просто для удобства, добавим группу clients наших будущих клиентов:
root@gw > vim /etc/bind/named.conf.local
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
acl clients {
127.0.0.1;
192.168.240.0/24;
};
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
acl clients {
127.0.0.1;
192.168.240.0/24;
};
Вот и закончили конфигурить 🙂
Теперь просто перезапускаем сервис командой:
root@gw > service bind9 restart
Правим /etc/resolv.conf примерно до такого вида:
root@gw > cat /etc/resolv.conf
search mydomain.com.ua
#nameserver 194.183.162.193
#nameserver 194.183.162.130
nameserver 127.0.0.1
root@gw >
search mydomain.com.ua
#nameserver 194.183.162.193
#nameserver 194.183.162.130
nameserver 127.0.0.1
root@gw >
И проверяем работоспособность нашего новоиспеченного сервиса:
root@gw > dig meta.ua
; <<>> DiG 9.7.3 <<>> meta.ua
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40189
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;meta.ua. IN A
;; ANSWER SECTION:
meta.ua. 6534 IN A 194.0.131.18
;; AUTHORITY SECTION:
meta.ua. 4970 IN NS ns4.top.net.ua.
meta.ua. 4970 IN NS ns5.top.net.ua.
;; ADDITIONAL SECTION:
ns4.top.net.ua. 235 IN A 88.81.249.204
ns5.top.net.ua. 235 IN A 88.81.254.204
;; Query time: 65 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 3 18:44:31 2011
;; MSG SIZE rcvd: 117
root@gw >
; <<>> DiG 9.7.3 <<>> meta.ua
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40189
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;meta.ua. IN A
;; ANSWER SECTION:
meta.ua. 6534 IN A 194.0.131.18
;; AUTHORITY SECTION:
meta.ua. 4970 IN NS ns4.top.net.ua.
meta.ua. 4970 IN NS ns5.top.net.ua.
;; ADDITIONAL SECTION:
ns4.top.net.ua. 235 IN A 88.81.249.204
ns5.top.net.ua. 235 IN A 88.81.254.204
;; Query time: 65 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 3 18:44:31 2011
;; MSG SIZE rcvd: 117
root@gw >
Как видите, нам ответил сервер 127.0.0.1#53(127.0.0.1) тоесть все работает на ура!
Если чтото идет нетак — смотрите логи в /var/log/daemon.log
Удачи 😉
Комментов пока нет