主从DNS的实现方法:
需要两大步:配置主DNS、配置从DNS
#####配置主DNS
第一步:
查看你的软件包是否安装
客户端需要安装bind ,bind-utils,bind-libs
服务器端:bind ,bind-utils
#yum list installed | grep bind
如果出现bind-utils,bind-libs而没有bind 软件包。说明bind-utils,bind-libs已经安装而bind没安装,做好你的yum源然后:
#yum install bind
第二步:
#vim /etc/named 修改nameserver选项指定一个可以上网的DNS(192.168.0.254为例)
nameserver 192.168.0.254
保存退出,这时一定要能上网,注意网关
#cd /var/named/
#dig –t NS . > /var/named/named.ca 注意 “点”别忘了,指定根域文件
第三步:
#vim localhost.zone 添加如下内容注意有很多 “点”不能漏掉
$TTL 86400
@ 1D IN SOA localhost. root.localhost. (
2010080301
1H
5M
7D
1D )
@ IN NS localhost.
localhost IN A 127.0.0.1
保存退出:wq
第四步:
#cp localhost.zone named.local
删除其中的localhost IN A 127.0.0.1 并添加 1 IN PTR localhost.
注意有很多 “点”不能漏掉
#vim named.local
$TTL 86400
@ 1D IN SOA localhost. root.localhost. (
2010080301
1H
5M
7D
1D )
@ IN NS localhost.
1 IN PTR localhost.
保存退出:wq
第五步:
创建a.com.zone文件并添加如下内容
#vim /var/named/a.com.zone
$TTL 86400
$ORIGIN a.com.
@ 1D IN SOA localhost. Dnsadmin.a.com. (
2010080301
1H
5M
7D
1D )
IN NS ns
IN MX 10 mail1
IN MX 10 mail2
ns IN A 192.168.0.53
mail1 IN A 192.168.0.54
mail2 IN A 192.168.0.55
www IN A 192.168.0.56
ftp IN A 192.168.0.57
web IN CNAME www
第六步:
编辑主配置文件,添加内容如下
#vim /etc/named.conf
options {
directory “/var/named”;
};
zone “.” IN {
type hint;
file “named.ca”
};
zone “localhost” IN {
type master;
file “localhost.zone”;
};
zone “0.0.127.in-addr.arpa” IN {
type master ;
file “named.local”;
};
zone “a.com” IN {
type master;
file “a.com.zone”
}
保存退出:wq
第七步:
修改文件属组
#chgrp named /etc/named.conf
#chgrp named /var/named/localhost.zone
#chgrp named /var/named/named.ca
#chgrp named /var/named/named.local
#chgrp named /var/named/a.com.zone
第八步:
启动服务并查看端口53 是否启动。
#service named start
#netstat –tunlp
第九步:
把DNS指向自己
#vim /etc/resolv.conf
nameserver 192.168.0.52 (也可以使用127.0.0.1)
配置从DNS
第一步:
#yum install bind
第二步:
#vim /etc/named
nameserver 192.168.0.254
保存退出
#cd /var/named/
#dig –t NS . > /var/named/named.ca 注意 “点”别忘了,指定根域文件
第三步:
#vim localhost.zone 添加如下内容注意有很多 “点”不能漏掉
$TTL 86400
@ 1D IN SOA localhost. root.localhost. (
2010080301
1H
5M
7D
1D )
@ IN NS localhost.
localhost IN A 127.0.0.1
保存退出:wq
第四步:
#cp localhost.zone named.local
删除其中的localhost IN A 127.0.0.1 并添加 1 IN PTR localhost.
注意有很多 “点”不能漏掉
#vim named.local
$TTL 86400
@ 1D IN SOA localhost. root.localhost. (
2010080301
1H
5M
7D
1D )
@ IN NS localhost.
1 IN PTR localhost.
保存退出:wq
第五步:
编辑主配置文件,添加内容如下
#vim /etc/named.conf
options {
directory “/var/named”;
};
zone “.” IN {
type hint;
file “named.ca”
};
zone “localhost” IN {
type master;
file “localhost.zone”;
};
zone “0.0.127.in-addr.arpa” IN {
type master ;
file “named.local”;
};
zone “a.com” IN {
type slave;
file “slaves/a.com.zone”
masters { masterIP ;};
};
masterIP 是主DNS的地址
保存退出:wq
第六步:
修改文件属组
#chgrp named /etc/named.conf
#chgrp named /var/named/localhost.zone
#chgrp named /var/named/named.ca
#chgrp named /var/named/named.local
第七步:
启动服务并查看端口53 是否启动。
#service named start
#netstat –tunlp
第八步:
把DNS指向主DNS
#vim /etc/resolv.conf
nameserver 192.168.0.52
这样主从DNS就ok了,可以测试一下
#dig –t A a.com