тип_запроса: A, PTR, NS, MX, AXFR
$ nslookup >ya.ru $ nslookup mx.bmstu.ru $ nslookup 195.19.32.1 $ nslookup -q=NS bmstu.ru val@noc:~$ nslookup -q=AXFR bmstu.ru 195.19.32.2 $ nslookup -q=MX bmstu.ru 195.19.32.2 $ nslookup -q=SRV _xmpp-client._tcp.bmstu.ru $ nslookup -q=SRV _kerberos._udp.bmstu.ru $ nslookup -q=SRV _sip._udp.bmstu.ru
$ host mx.bmstu.ru $ host 195.19.32.1 $ host -t NS bmstu.ru $ host -v -t NS . $ host -v -t NS ru. 192.33.4.12 $ host -v -t NS bmstu.ru. 194.190.124.17 $ host -t MX bmstu.ru 195.19.32.2 $ host -t AXFR bmstu.ru 195.19.32.2
$ dig mx.bmstu.ru $ dig -x 195.19.32.1 $ dig NS bmstu.ru $ dig MX bmstu.ru @195.19.32.2 $ dig AXFR bmstu.ru @195.19.32.2
gate# cat /etc/resolv.conf
domain corpX.un nameserver 192.168.X.10
server# cat /etc/resolv.conf
domain corpX.un nameserver 127.0.0.1
root@server:~# apt install bind9
# yum install bind bind-utils -y # systemctl enable named
[server:~] # pkg install bind99 [server:~] # cat /usr/local/etc/namedb/named.conf
options { directory "/usr/local/etc/namedb/working"; pid-file "/var/run/named/pid"; allow-recursion { any; }; }; zone "." { type hint; file "/usr/local/etc/namedb/named.root"; };
[server:~] # named-checkconf [server:~] # service named rcvar [server:~] # cat /etc/rc.conf
... named_enable="YES" ...
[server:~] # service named start
root@server:~# cat /etc/bind/named.conf.options
... forwarders { 172.16.1.254; }; ... // dnssec-validation auto; ... };
root@server:~# named-checkconf root@server:~# service bind9 restart
server# cat named.conf
options { ... forwarders { 172.16.1.254; }; ... }; ...
[server:~] # named-checkconf [server:~] # service named restart
server# cat /etc/bind/corpX.un
$TTL 3h corpX.un. SOA ns root.server 1 1d 12h 1w 3h NS ns ; A 192.168.X.10 ; MX 1 server ; MX 2 gate ns A 192.168.X.10 server A 192.168.X.10 gate A 192.168.X.1 ;test 1h IN A 192.168.X.10 ;nfs CNAME server ;samba CNAME server ;ftp CNAME server ;www CNAME server ;user1 CNAME server ;mail CNAME server ;ntp CNAME gate ;proxy A 172.16.1.X ;$GENERATE 1-100 node$ A 192.168.X.$ ;$GENERATE 1-9 node$ A 192.168.X.20$ ;$GENERATE 10-54 node$ A 192.168.X.2$ ;$GENERATE 1-9 kube$ A 192.168.X.22$ ;_sip._udp SRV 0 0 5060 server ;_xmpp-client._tcp SRV 0 0 5222 server ;_kerberos._udp SRV 01 00 88 server ;_kerberos._tcp SRV 01 00 88 server ;_kerberos TXT CORPX.UN
server# named-checkzone corpX.un /etc/bind/corpX.un
root@server:~# cat /etc/bind/named.conf.local
... zone "corpX.un" { type master; file "/etc/bind/corpX.un"; };
root@server:~# named-checkconf -z root@server:~# rndc reload
server# nslookup -q=A server.corpX.un
server# cat /etc/bind/corpX.un
$TTL 3h corpX.un. SOA ns root.server 1 1d 12h 1w 3h NS ns NS ns.isp.un. ...
server# named-checkzone corpX.un /etc/bind/corpX.un server# rndc reload
server# nslookup -q=AXFR compX.un ns.isp.un
root@server:~# cat /etc/bind/named.conf.local
... zone "compX.un" { type slave; file "/var/cache/bind/compX.un"; masters { 172.16.1.254; }; };
root@server:~# named-checkconf -z root@server:~# rndc reload root@server:~# ls /var/cache/bind/ root@server:~# named-compilezone -f raw -F text -o - compX.un /var/cache/bind/compX.un
ns.un# cat un
... ns.isp A 172.16.1.254 ... ns.corp1 A 192.168.1.10 ... ns.corp16 A 192.168.16.10 corp1 NS ns.corp1.un. NS ns.isp.un. ... corp16 NS ns.corp16.un. NS ns.isp.un. ...
ns.un# cat named.conf
... zone "corp1.un" IN { type forward; forwarders { 192.168.1.10; 172.16.1.254; }; }; ... zone "corp16.un" IN { type forward; forwarders { 192.168.16.10; 172.16.1.254; }; }; ...
server# cat /etc/bind/corpX.rev
$TTL 3h @ SOA ns.corpX.un. root.server.corpX.un. 1 1d 12h 1w 3h NS ns.corpX.un. 1 PTR gate.corpX.un. 10 PTR server.corpX.un.
server# named-checkzone X.168.192.IN-ADDR.ARPA /etc/bind/corpX.rev
root@server:~# cat /etc/bind/named.conf.local
... zone "X.168.192.IN-ADDR.ARPA" { type master; file "/etc/bind/corpX.rev"; };
root@server:~# named-checkconf -z root@server:~# service bind9 restart
server# nslookup -q=PTR 192.168.X.10 server# nslookup -q=A server.corpX.un
Создание файла зоны corpX.un для внутренних и внешних пользователей
server# cat /etc/bind/corpX.un
$TTL 3h corpX.un. SOA ns root.server 1 1d 12h 1w 3h NS ns MX 1 server A 192.168.X.10 ns A 192.168.X.10 server A 192.168.X.10 gate A 192.168.X.1 ...
server# cat /etc/bind/corpX.un.out
$TTL 3h corpX.un. SOA ns root.server 1 1d 12h 1w 3h NS ns NS ns.isp.un. MX 1 server A 172.16.1.X ns A 172.16.1.X server A 172.16.1.X gate A 172.16.1.X mail CNAME server ;...
Настройка сервера
root@server:~# less /etc/bind/named.conf.local
zone "corpX.un" { type master; file "/etc/bind/corpX.un"; }; zone "X.168.192.IN-ADDR.ARPA" { type master; file "/etc/bind/corpX.rev"; };
root@server:~# cat /etc/bind/named.conf
include "/etc/bind/named.conf.options"; view "inside" { match-clients { 192.168.X/24; 127/8; }; include "/etc/bind/named.conf.local"; include "/etc/bind/named.conf.default-zones"; }; view "outside" { zone "corpX.un" { type master; file "/etc/bind/corpX.un.out"; }; };
root@server:~# service bind9 restart
server# mv /usr/local/etc/namedb/master/corp* /usr/local/etc/namedb/dynamic/ server# scp /usr/local/etc/namedb/rndc.key gate:/usr/local/etc/ server# cat /usr/local/etc/namedb/named.conf
... zone "corpX.un" { allow-update { key "rndc-key"; }; file "/usr/local/etc/namedb/dynamic/corpX.un"; ... zone "X.168.192.IN-ADDR.ARPA" { allow-update { key "rndc-key"; }; file "/usr/local/etc/namedb/dynamic/corpX.rev"; ... include "rndc.key";
server# mv /etc/bind/corp* /var/cache/bind/ server# chown -R bind /var/cache/bind/ server# scp /etc/bind/rndc.key gate:/etc/dhcp/ server# ssh gate "chown dhcpd /etc/dhcp/rndc.key" server# cat /etc/bind/named.conf
... zone "corpX.un" { ... allow-update { key "rndc-key"; }; }; ... zone "X.168.192.IN-ADDR.ARPA" { ... allow-update { key "rndc-key"; }; }; ... include "/etc/bind/rndc.key";
# cat /etc/bind/named.conf.options
options { ... allow-recursion {192.168.X/24; 192.168.100+X/24; 127/8;}; ... };
# cat /etc/bind/named.conf.local
zone "corpX.un" { ... allow-transfer {172.16.1.254;}; ... };
gate.isp.un$ nslookup -q=AXFR corpX.un 192.168.X.10
# cat named.conf
options { ... dump-file "/tmp/named_dump.db"; statistics-file "/tmp/named.stats"; ... };
# rndc dumpdb -cache # less /var/cache/bind/named_dump.db
[server:~] # rndc stats [server:~] # cat /var/named/var/stats/named.stats success - число запросов, не вызвавших ошибок или возврата клиенту ссылки referral - число запросов, на которые сервер вернул клиенту ссылки nxrrset - несуществующих записей запрошенного типа для доменного имени nxdomain - несуществующих доменных имен recursion - число запросов, потребовавших рекурсивной обработки failure - число ошибок, кроме nxrrset и nxdomain