在缓存名称dns的基础上添加正向和反向的dns解析
在/etc/named.conf中加入以一个新域 a.org.zone:
Zone “a.org” IN {
Type master;
File “a.org.zone”;
};
然后要编辑创建a.org.zone
Vim /var/named/a.org.zone
$TTL 1200
@
IN SOA ns1.a.org. admin.a.org. (
2011081801
1D
10M
7D
1D )
IN NS ns1.a.org.
IN NS ns2.a.org.
ns1.a.org.
IN A 192.168.0.73
ns2.a.org.
IN A 192.168.0.72
mail.a.org.
IN A 192.168.0.74
www.a.org.
IN A 192.168.0.73
bbs.a.org.
IN CNAME www.a.org.
ftp.a.org.
IN A 192.168.0.100
编辑保存之后要把a.org.zone的属组改为named
Chown
:named /var/named/a.org.zone
查看文件属性 ll /var/named/a.org.zone
-rw-r--r-- 1 root named 834 Aug 17 21:39 /var/named/a.org.zone
改了配置文件之后我们 千万要记住重新载入服务
Service named reload 或者 service named restart
然后要看下/etc/resolv.conf 把nameserver的ip确定 为127.0.0.1
如果重启成功我们就可以测试一下了
Dig -t A
www.a.org
显示的结果如下:
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t A www.a.org
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7814
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;www.a.org.
IN A
;; ANSWER SECTION:
www.a.org.
1200 IN A 192.168.0.73
;; AUTHORITY SECTION:
a.org.
1200 IN NS ns2.a.org.
a.org.
1200 IN NS ns1.a.org.
;; ADDITIONAL SECTION:
ns1.a.org.
1200 IN A 192.168.0.73
ns2.a.org.
1200 IN A 192.168.0.72
;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 17 21:36:05 2011
;; MSG SIZE rcvd: 111
到这里正向的就做完了,下边要做反向的 在/etc/named.conf 文件 中加入如下:
zone "0.168.192.in-addr.arpa" IN {
type master;
file "192.168.0.zone";
};
然后就可以创建192.168.0.zone了 这里可以直接cp /var/named/a.org.zone 并进行编辑修改
; cp /var/named/a.org.zone /var/named/192.168.0.zone
Vim /var/named/192.168.0.zone
$TTL 1200
@
IN SOA ns1.a.org. admin.a.org. (
2011081801
1D
10M
7D
1D )
IN NS ns1.a.org.
IN NS ns2.a.org.
73
IN PTR ns1.a.org.
72
IN PTR ns2.a.org.
74
IN PTR mail.a.org.
73
IN PTR www.a.org.
100
IN PTR ftp.a.org.
然后可以测试下其是否有语法错误
[root@station73 ~]# named-checkzone "0.168.192.in-addr.arpa" /var/named/192.168.0.zone
显示如下
zone 0.168.192.in-addr.arpa/IN: loaded serial 2011081801
OK
重启named服务
重启服务后可以测试 了
Dig
-x 192.168.0.73 显示如下
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -x 192.168.0.73
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26142
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;73.0.168.192.in-addr.arpa.
IN PTR
;; ANSWER SECTION:
73.0.168.192.in-addr.arpa. 1200
IN PTR ns1.a.org.
73.0.168.192.in-addr.arpa. 1200
IN PTR www.a.org.
;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 1200
IN NS ns2.a.org.
0.168.192.in-addr.arpa. 1200
IN NS ns1.a.org.
;; ADDITIONAL SECTION:
ns1.a.org.
1200 IN A 192.168.0.73
ns2.a.org.
1200 IN A 192.168.0.72
;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 17 22:15:59 2011
;; MSG SIZE rcvd: 148
这样完整的dns就建立起来了
转载于:https://blog.51cto.com/lvsir666/642202