三台主机(两个也行):
DNS-Master:192.168.8.11
DNS-Slave:192.168.8.12
DNS-Slaver:192.168.8.13
======================================
正向解析:
Master:
yum install bind -y
vim /etc/named.conf ##
12 options {
13 listen-on port 53 { any; }; ##监听端口
15 directory "/var/named"; ##正反解的zone文件放置位置
19 allow-query { any; }; ##表示谁可以对此DNS服务>器进行查询
31 recursion yes; ##是否进行递归查询
57 zone "bss.com" IN { ##设定自己的域
58 type master;
59 file "bss.com.zone";
60 };
[root@dns named]# vim /var/named/bss.com.zone
@ IN SOA dns.bss.com. dns (
201908
1D
1H
1W
1H )
@ IN NS dns.bss.com.
dns.bss.com. A 192.168.8.11
www A 192.168.8.12
ftp A 192.168.8.13
[root@dns named]# systemctl restart named
[root@dns named]vim /etc/resolv.conf
nameserver 192.168.8.11
同时,要将自己创建的域文件的用户组更改为named,并更改权限与当前目录文件的权限相同为640
测试:
[root@dns named]# host www.bss.com
www.bss.com has address 192.168.8.12
[root@dns named]# host ftp.bss.com
ftp.bss.com has address 192.168.8.13
[root@dns named]# host dns.bss.com
dns.bss.com has address 192.168.8.11
[root@dns named]# dig www.bss.com
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22082
......
;www.bss.com. IN A
;; ANSWER SECTION:
www.bss.com. 3600 IN A 192.168.8.12
;; AUTHORITY SECTION:
bss.com. 3600 IN NS dns.bss.com.
;; ADDITIONAL SECTION:
dns.bss.com. 3600 IN A 192.168.8.11
......
==============================================
反向解析:
Master:
[root@dns named]# vim /etc/named.conf
zone "8.168.192.in-addr.arpa" IN { ##定义反向解析的域
type master;
file "bss.arpa.zone";
};
cd /var/named/
[root@dns named]# cp -a bss.com.zone bss.arpa.zone
[root@dns named]# vim bss.arpa.zone
@ IN SOA dns.bss.com. dns (
201908
1D
1H
1W
1H )
@ IN NS dns.bss.com.
11 PTR dns.bss.com.
12 PTR www.bss.com.
13 PTR ftp.bss.com.
[root@dns named]# systemctl restart named
##测试:
[root@dns named]# host 192.168.8.11
11.8.168.192.in-addr.arpa domain name pointer dns.bss.com.
[root@dns named]# host 192.168.8.12
12.8.168.192.in-addr.arpa domain name pointer www.bss.com.
[root@dns named]# host 192.168.8.13
13.8.168.192.in-addr.arpa domain name pointer ftp.bss.com.
[root@dns named]# dig -x 192.168.8.13
...
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11890
...
13.8.168.192.in-addr.arpa. 3600 IN PTR ftp.bss.com.
;; AUTHORITY SECTION:
8.168.192.in-addr.arpa. 3600 IN NS dns.bss.com.
;; ADDITIONAL SECTION:
dns.bss.com. 3600 IN A 192.168.8.11
...