[root@server named]# vim /etc/named.conf[root@server named]# cat /etc/named.conf
options {
listen-on port 53{192.168.21.128;};
directory "/var/named";};
zone "qq.com" IN {type master;file"named.qq.com";};
zone "163.com" IN {type master;file"named.163.com";};
创建/var/named/named.qq.com
[root@server named]# vim /var/named/named.qq.com [root@server named]# cat /var/named/named.qq.com $TTL 1D
@ IN SOA master.qq.com. admin.qq.com. (1942; serial
1D ; refresh
1H ; retry
1W ; expire
3H ); minimum
IN NS master.qq.com.
master IN A 192.168.21.128
www IN A 192.168.21.1
wwww IN CNAME www
创建/var/named/named.163.com
[root@server named]# vim /var/named/named.163.com [root@server named]# cat /var/named/named.163.com $TTL 1D
@ IN SOA master.163.com. admin.163.com. (1942; serial
1D ; refresh
1H ; retry
1W ; expire
3H ); minimum
IN NS master.163.com.
master IN A 192.168.21.128
www IN A 192.168.21.3
wwww IN CNAME www
验证解析
[root@server named]# dig @192.168.21.128 www.qq.com;<<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> @192.168.21.128 www.qq.com
;(1 server found);; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9043;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232; COOKIE: ce63a594619a9ddefbdd18b46377af356869e8236ce96dfb (good);; QUESTION SECTION:
;www.qq.com. IN A
;; ANSWER SECTION:
www.qq.com. 86400 IN A 192.168.21.1
;; AUTHORITY SECTION:
qq.com. 86400 IN NS master.qq.com.
;; ADDITIONAL SECTION:
master.qq.com. 86400 IN A 192.168.21.128
;; Query time: 0 msec
;; SERVER: 192.168.21.128#53(192.168.21.128);; WHEN: Sat Nov 19 00:13:41 CST 2022;; MSG SIZE rcvd: 120[root@server named]# dig @192.168.21.128 www.163.com;<<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> @192.168.21.128 www.163.com
;(1 server found);; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15868;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232; COOKIE: b2cf5592402bb674be7b883e6377af3b9600f82eeef02b1a (good);; QUESTION SECTION:
;www.163.com. IN A
;; ANSWER SECTION:
www.163.com. 86400 IN A 192.168.21.3
;; AUTHORITY SECTION:
163.com. 86400 IN NS master.163.com.
;; ADDITIONAL SECTION:
master.163.com. 86400 IN A 192.168.21.128
;; Query time: 0 msec
;; SERVER: 192.168.21.128#53(192.168.21.128);; WHEN: Sat Nov 19 00:13:47 CST 2022;; MSG SIZE rcvd: 121