在CentOS上安装BIND作为辅助(从)DNS服务器
在安装了BIND作为主DNS服务器(NS1)(如我最近的帖子中所述) 之后 ),我们现在可以尝试在CentOS上使用BIND设置辅助DNS服务器(NS2)。 如果NS1有问题,NS2将作为备份。
确保您已成功设置NS1,如我上一篇文章所述!
NS1与IP 192.168.0.1
NS2 IP为192.168.0.2
我们的域名: yourdomain.com
现在我们可以尝试设置NS2。
1.检查您的绑定包装
[root@server ~]# rpm -qa bind*
bind-libs-9.2.4-2
bind-utils-9.2.4-2
bind-9.2.4-2
2.设置文件/etc/resolv.conf
[root@server ~]# nano /etc/resolv.conf
nameserver 192.168.0.1
3.设置文件/etc/named.conf
[root@server ~]# nano /etc/named.conf
// // named.conf for Red Hat caching-nameserver // options { directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; /* * If there is a firewall between you and nameservers you want * to talk to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an unprivileged * port by default. */ // query-source address * port 53; allow-transfer {208.99.198.184/32;}; }; // // a caching only nameserver config // controls { inet 127.0.0.1 allow { localhost; } keys { rndckey; }; }; zone "localhost" IN { type master; file "localhost.zone"; allow-update { none; }; }; zone "yourdomain.com" IN { type slave; file "/var/named/yourdomain.com.zone"; // allow-update { none; }; allow-transfer { 192.168.0.1/32; }; masters { 192.168.0.1; }; }; zone "0.168.192.in-addr.arpa" IN { type slave; file "/var/named/0.168.192.rev"; // allow-update { none; }; allow-transfer { 192.168.0.1/32; }; masters { 192.168.0.1; }; }; include "/etc/rndc.key";
4.更改目录/ var / named的权限
[root@server ~]# chmod 777 -Rvf /var/named/
mode of `/var/named/’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.zero’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localhost.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/data’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ca’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ip6.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localdomain.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.broadcast’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/slaves’ changed to 0777 (rwxrwxrwx)
5.文件/var/named/yourdomain.com和/var/named/0.168.192.rev将自动复制到NS2。
运行服务命名
[root@server ~]# service named restart
Stopping named: [ OK ]
开始命名:[OK]
7.检查日志文件有什么事情?
[root@server ~]# tail /var/log/messages
8月3日04:25:42服务器命名[9362]:监听IPv4接口venet0:0,192.168.0.2#53
8月3日04:25:42服务器命名[9362]:命令通道监听127.0.0.1#953
8月3日04:25:42服务器命名[9362]:zone localhost / IN:loaded serial 42
8月3日04:25:42服务器命名[9362]:运行
8月3日04:25:42服务器命名[9362]:zone yourdomain.com/IN:传送串行100
8月3日04:25:42服务器命名[9362]:传输'yourdomain.com/IN'从192.168.0.1#53:转移结束
8月3日04:25:42服务器命名[9362]:zone yourdomain.com/IN:发送通知(串口100)
8月3日04:25:43服务器命名[9362]:区域0.168.192.in-addr.arpa/IN:传输串行100
8月3日04:25:43服务器命名[9362]:传输'0.168.192.in-addr.arpa/IN'从192.168.0.1#53:转移结束
8月3日04:25:43服务器命名[9362]:区域0.168.192.in-addr.arpa/IN:发送通知(串行100)
看这个日志,你可以看到yourdomain.com
区域被转移了。 实际上,这个文件被复制到NS2,所以如果NS1死机或有问题,NS2有备份配置。
8.结果使用nslookup
[root@server ~]# nslookup yourdomain.com
Server: 192.168.0.1
Address: 192.168.0.1#53
Name: yourdomain.com
Address: 192.168.0.1
answered from nslookup used server from NS1 with IP 192.168.0.1
现在我们可以尝试停用NS1,看看名称解析是否仍然有效。
首先添加Nameservers192.168.0.2
[root@server ~]# cat /etc/resolv.conf
nameserver 192.168.0.1
nameserver 192.168.0.2
该域正在使用NS2,因为NS1不活动。 我们不需要更改NS2上的任何文件,因为所有区域文件都从NS1传输到NS2。
10.尝试在NS1关闭时进行DNS查找
[root@server ~]# nslookup yourdomain.com
Server: 192.168.0.2
Address: 192.168.0.2#53
Name: yourdomain.com
Address: 192.168.0.1
现在如果NS1有任何问题,你可以安心,因为NS2作为备份。