master and slave DNS
们要架设一个本地主从dns服务器一般需按一下三个软件软件:
bind.i386
bind-libs.i386 提供库文件
bind-utils.i386 提供工具
环境:
主DNS ip :192.168.0.1 从DNS ip:192.168.0.190
主(master)DNS的设置:
解析文件位置:
/var/named/
本地反解
127.0.0.zone文件
$TTL 1D
@ 86400 IN SOA localhost. root.localhost. ( 2010080301 1D 5M 7D 1D )
IN NS localhost.
1 IN PTR localhost.
本地正解
localhost.zone文件
$TTL 1D
@ 86400 IN SOA localhost. root.localhost. ( 2010080301 1D 5M 7D 1D )
IN NS localhost.
localhost. IN A 127.0.0.1
根文件,这里面方的是全球的13个根(当缓存中没有相应相应的ip对应的域名时,本DNS服务器回去找根DNS服务器}
named.ca
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t .
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37165
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 14
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 492108 IN NS j.root-servers.net.
. 492108 IN NS k.root-servers.net.
. 492108 IN NS l.root-servers.net.
. 492108 IN NS m.root-servers.net.
. 492108 IN NS a.root-servers.net.
. 492108 IN NS b.root-servers.net.
. 492108 IN NS c.root-servers.net.
. 492108 IN NS d.root-servers.net.
. 492108 IN NS e.root-servers.net.
. 492108 IN NS f.root-servers.net.
. 492108 IN NS g.root-servers.net.
. 492108 IN NS h.root-servers.net.
. 492108 IN NS i.root-servers.net.
;; ADDITIONAL SECTION:
b.root-servers.net. 588150 IN A 192.228.79.201
c.root-servers.net. 588151 IN A 192.33.4.12
d.root-servers.net. 588152 IN A 128.8.10.90
e.root-servers.net. 588152 IN A 192.203.230.10
f.root-servers.net. 588153 IN A 192.5.5.241
f.root-servers.net. 588153 IN AAAA 2001:500:2f::f
g.root-servers.net. 588154 IN A 192.112.36.4
h.root-servers.net. 588155 IN A 128.63.2.53
h.root-servers.net. 588155 IN AAAA 2001:500:1::803f:235
i.root-servers.net. 588156 IN A 192.36.148.17
i.root-servers.net. 588156 IN AAAA 2001:7fe::53
j.root-servers.net. 588157 IN A 192.58.128.30
j.root-servers.net. 588157 IN AAAA 2001:503:c27::2:30
k.root-servers.net. 588158 IN A 193.0.14.129
;; Query time: 1 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Tue Aug 3 15:30:03 2010
;; MSG SIZE rcvd: 500
注意:改文件的属主
chgrp named /var/named/{127.0.0.zone,named.ca,localhost.zone}
主配置文件:
/etc/named.conf
options{
directory "/var/named";
};
zone "." IN {
type hint ;
file "name.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr-arpa" IN {
type master;
file "127.0.0.zone";
};
zone "a.com" IN {
type master;
file "a.com.zone";
allow-transfer{192.168.0.190;};
};
zone "0.168.192.in-addr-arpa" IN {
type master;
file "192.168.0.zone";
allow-transfer{192.168.0.190;};
};
从(slave)DNS的设置:
a.从DNS的本地解析(本地缓存dns)与主DNS的一样
b.从dns的/etc/named.conf与主DNS的设置类似,惟一的差别是两个zone的类型不同,如下
vim /etc/named.conf
.....
zone "a.com" IN {
type slave;
file "slaves/a.com.zone";
masters { 192.168.0.1; };
allow-transfer { none; };
}
zone "0.168.192.in-addr.arpa" IN {
type slave;
file "slaves/192.168.0.zone";
masters { 192.168.0.1; };
allow-transfer { none; };
};
注意改文件属主:
chgrp named /etc/named.conf
到此你是不是有疑问:192.168.0.zone和a.com.zone两个文件还没有配置
注意:从dns的192.168.0.zone和a.com.zone两个文件是从主dns那里同步过来的