结合我的这篇文章看:http://my.oschina.net/zhangxc73912/blog/300871
平台RHEL6.3
虚拟接3台:ACE1.example.com 192.168.10.3
ACE2.example.com 192.168.0.4
ACE3.example.com eth0:192.168.0.5
eth1:192.168.10.5
编辑文件named.conf
[root@ACE3 etc]# pwd
/var/named/chroot/etc
[root@ACE3 etc]# vim named.conf
#zone "." IN {
# type hint;
# file "named.ca";
#};
#include "/etc/named.rfc1912.zones";
添加
view dns1 {
match-clients {192.168.0.0/24};
zone "."IN {
type hint;
file "named.ca";
};
zone "example.com" IN{
type master;
file "example.com.zone";
allow-update { none; };
};
};
view dns2 {
match-clients {192.168.10.0/24};
zone "."IN {
type hint;
file "named.ca";
};
zone "example.com" IN{
type master;
file "example.com.zone1";
allow-update { none; };
};
};
添加文件example.com.zone1
[root@ACE3 named]# pwd
/var/named
[root@ACE3 named]# cp -p example.com.zone example.com.zone1
[root@ACE3 named]# ll
-rw-r----- 1 root named 192 Aug 12 17:15 example.com.zone1
[root@ACE3 named]# vim example.com.zone1
$TTL 1D
@ IN SOA ACE3.example.com. root.example.com (
0
1D
1H
1W
3H )
NS ACE3.example.com.
ACE3.example.com. A 192.168.10.5
zhangxc CNAME www
www A 192.168.10.5
ww A 192.168.10.5
重启服务&测试:
ACE2:
[root@ACE2 ~]# dig zhangxc.example.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> zhangxc.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18832
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;zhangxc.example.com. IN A
;; ANSWER SECTION:
zhangxc.example.com. 86400 IN CNAME www.example.com.
www.example.com. 86400 IN A 192.168.0.7
;; AUTHORITY SECTION:
example.com. 86400 IN NS ACE3.example.com.
;; ADDITIONAL SECTION:
ACE3.example.com. 86400 IN A 192.168.0.5
;; Query time: 48 msec
;; SERVER: 192.168.0.5#53(192.168.0.5)
;; WHEN: Tue Aug 12 18:23:33 2014
;; MSG SIZE rcvd: 106
ACE1:
root@ACE1 ~]# dig zhangxc.example.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> zhangxc.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3131
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;zhangxc.example.com. IN A
;; ANSWER SECTION:
zhangxc.example.com. 86400 IN CNAME www.example.com.
www.example.com. 86400 IN A 192.168.10.5
;; AUTHORITY SECTION:
example.com. 86400 IN NS ACE3.example.com.
;; ADDITIONAL SECTION:
ACE3.example.com. 86400 IN A 192.168.10.5
;; Query time: 60 msec
;; SERVER: 192.168.10.5#53(192.168.10.5)
;; WHEN: Tue Aug 12 18:34:40 2014
;; MSG SIZE rcvd: 106
ok!!!!
也上只是正向的解析
反向同理在里面只要添加相应的代码即可! 参照我上一篇博客!!!!!!