★增加一个域名(zone)
- vim /etc/named.conf 修改主配置文件
zone "hera.com" IN {
type master;
file "hera.com.zone";
};
zone "16.168.192.in-addr.arpa" IN { <== 反解析zone,IP是反着写的,192.168.16.*
type master;
file "192.168.zone";
};
- 编辑zone文件: vim /var/named/hera.com.zone
增加以下内容:
$TTL 600 <== 600秒过期
@ IN SOA hera.com. root.hera.com. (
2013081601
1H
10M
7D
1D
)
IN NS ns.hera.com.
IN MX 10 mail.hera.com.
ns IN A 192.168.16.100
www IN A 192.168.16.100
mail IN A 192.168.16.10
bbs IN CNAME www.hera.com. - 编辑反解析文件: vim /var/named/192.168.zone
增加以下内容:
$TTL 600
@ IN SOA ns.hera.com. root.hera.com. (
2013081601
1H
10M
7D
1D
)
@ IN NS ns.hera.com.
10 IN PTR ns.hera.com.
11 IN PTR mail.hera.com.
73 IN PTR www.hera.com. - 检测配置文件是否有问题
要注意,检测之前我们一定要先进入/var/named下
named-checkzone "hera.com" hera.com.zone
[[email protected] named]# named-checkzone "hera.com" hera.com.zone
zone hera.com/IN: loaded serial 2013081601
OK
named-checkzone "16.168.192.in-addr.arpa" 192.168.zone
[[email protected] named]# named-checkzone "16.168.192.in-addr.arpa" 192.168.zone
zone 16.168.192.in-addr.arpa/IN: loaded serial 2013081601
OK
- 重启named服务:service named restart
- 测试:
正向解析:
[[email protected] named]# dig @127.0.0.1 www.hera.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.1 <<>> @127.0.0.1 www.hera.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4676
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1;; QUESTION SECTION:
;www.hera.com. IN A;; ANSWER SECTION:
www.hera.com. 600 IN A 192.168.16.100;; AUTHORITY SECTION:
hera.com. 600 IN NS ns.hera.com.;; ADDITIONAL SECTION:
ns.hera.com. 600 IN A 192.168.16.100;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Feb 4 05:47:33 2015
;; MSG SIZE rcvd: 79反向解析:
[[email protected] named]# dig @127.0.0.1 -x 192.168.16.100
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.1 <<>> @127.0.0.1 -x 192.168.16.100
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 9473
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0;; QUESTION SECTION:
;100.16.168.192.in-addr.arpa. IN PTR;; AUTHORITY SECTION:
16.168.192.in-addr.arpa. 600 IN SOA ns.hera.com. root.hera.com. 2013081601 3600 600 604800 86400;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Feb 4 05:49:40 2015
;; MSG SIZE rcvd: 97 - 我们再向主配置文件中加入两行 /var/named/hera.com.zone
yue IN A 0.0.0.0
sky IN CNAME mail
测试正向解析:
[[email protected] named]# dig @127.0.0.1 yue.hera.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.1 <<>> @127.0.0.1 yue.hera.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64186
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;yue.hera.com. IN A
;; ANSWER SECTION:
yue.hera.com. 600 IN A 0.0.0.0
;; AUTHORITY SECTION:
hera.com. 600 IN NS ns.hera.com.
;; ADDITIONAL SECTION:
ns.hera.com. 600 IN A 192.168.16.100
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Feb 4 06:08:34 2015
;; MSG SIZE rcvd: 79
-------------------------------------------------
[[email protected] named]# dig @127.0.0.1 sky.hera.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.1 <<>> @127.0.0.1 sky.hera.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54472
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;sky.hera.com. IN A
;; ANSWER SECTION:
sky.hera.com. 600 IN CNAME mail.hera.com. <== 自动补上 .hera.com.
mail.hera.com. 600 IN A 192.168.16.10
;; AUTHORITY SECTION:
hera.com. 600 IN NS ns.hera.com.
;; ADDITIONAL SECTION:
ns.hera.com. 600 IN A 192.168.16.100
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Feb 4 06:10:48 2015
;; MSG SIZE rcvd: 98