标签:dns服务器
当一个域内主DNS宕机或者压力过高时就需要在添加一台DNS服务器用来顶替主DNS或者缓解主DNS的压力。
主机规划:
角色 | IP地址 | 主机名 |
DNS-MASTER | 192.168.233.135 | dns_master |
DNS-SLAVE | 192.168.233.134 | dns_slave |
向区域中添加从服务器的关键两步步:
(在上级获得授权)
在区域数据文件中为从服务器添加一条NS记录和对应的A记录;
[root@dns_slave ~]# yum -y install bind [root@dns_slave ~]# mv /etc/named.conf/etc/named.conf.ori [root@dns_slave ~]# vim /etc/named.conf options { directory "/var/named/"; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "named.localhost"; }; zone "1.0.0.127.in-addr.arpa"IN { type master; file "named.loopback"; }; zone "enzhi.com." IN { type slave; masters { 192.168.233.135; }; file "slaves/enzhi.com.zone"; }; zone"233.168.192.in-addr.arpa" IN { type slave; masters { 192.168.233.135; }; file "slaves/192.168.233.zone"; };
#masters { DNS_SERVER_IP; }; 指定主DNS服务器IP地址
注意:
#从服务器的区域数据文件不需要自己创建,从服务器会自动的从主服务器上复制到从服务器中的/var/named/slaves/目录下。所以从服务器的区域配置文件中file的路径要写相对路径file"slaves/enzhi.com.zone";
#在主服务器的zone中添加一行allow-transfer{ SLAVE_SERVER_IP;};允许某个从服务器可以复制区域数据文件。
[root@dns_master named]# vi /etc/named.conf options { directory "/var/named"; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "named.localhost"; }; zone "1.0.0.127.in-addr.apra"IN { type master; file "named.loopback"; }; zone "enzhi.com." IN { type master; file "enzhi.com.zone"; allow-transfer { 192.168.233.134; }; }; zone"233.168.192.in-addr.arpa" IN { type master; file "192.168.233.zone"; allow-transfer { 192.168.233.134; }; };
[root@dns_master named]# vimenzhi.com.zone $TTL 600 @ IN SOA ns.enzhi.com. admin.enzhi.com. ( 2016032401 2H 5M 7D 1D ) IN NS ns IN NS ns2 IN MX 10 mail ns IN A 192.168.233.135 ns2 IN A 192.168.233.134 mail IN A 192.168.233.11 www IN A 192.168.233.10 ftp IN CNAME www
#修改反向区域数据文件
[root@dns_master named]# vim 192.168.233.zone $TTL 600 @ IN SOA ns.enzhi.com. admin.enzhi.com. ( 2016032401 2H 5M 7D 1D ) @ IN NS ns.enzhi.com. IN NS ns2.enzhi.com. 135 IN PTR ns.enzhi.com. 134 IN PTR ns2.enzhi.com. 11 IN PTR mail.enzhi.com. 10 IN PTR www.enzhi.com.
#语法检查并重启nsmed服务
[root@dns_master named]# named-checkzone"233.168.192.in-addr.arpa" 192.168.233.zone zone 233.168.192.in-addr.arpa/IN: loadedserial 2016032401 OK [root@dns_master named]#/etc/init.d/named reload Reloading named: [ OK ]
[root@dns_slave ~]# /etc/init.d/namedconfigtest #语法检查 zone localhost/IN: loaded serial 0 zone 1.0.0.127.in-addr.arpa/IN: loadedserial 0 [root@dns_slave ~]# /etc/init.d/namedstart #启动named Generating /etc/rndc.key: [ OK ] Starting named: [ OK ] #检查区域数据文件是否成功复制过来 [root@dns_slave ~]# cd/var/named/slaves/ [root@dns_slave slaves]# ls 192.168.233.zone enzhi.com.zone
[root@dns_slave slaves]# dig -t A www.enzhi.com @192.168.233.134 ; <<>> DiG9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.7 <<>> -t A www.enzhi.com@192.168.233.134 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status: NOERROR, id: 15935 ;; flags: qr aa rd ra; QUERY: 1, ANSWER:1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;www.enzhi.com. IN A ;; ANSWER SECTION: www.enzhi.com. 600 IN A 192.168.233.10 ;; AUTHORITY SECTION: enzhi.com. 600 IN NS ns2.enzhi.com. enzhi.com. 600 IN NS ns.enzhi.com. ;; ADDITIONAL SECTION: ns.enzhi.com. 600 IN A 192.168.233.135 ns2.enzhi.com. 600 IN A 192.168.233.134 ;; Query time: 1 msec ;; SERVER:192.168.233.134#53(192.168.233.134) ;; WHEN: Thu Mar 24 12:43:39 2016 ;; MSG SIZE rcvd: 114
#反向解析
[root@dns_slave slaves]# dig -x192.168.233.10 @192.168.233.134 ; <<>> DiG9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.7 <<>> -x 192.168.233.10@192.168.233.134 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status: NOERROR, id: 28690 ;; flags: qr aa rd ra; QUERY: 1, ANSWER:1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;10.233.168.192.in-addr.arpa. IN PTR ;; ANSWER SECTION: 10.233.168.192.in-addr.arpa. 600 IN PTR www.enzhi.com. ;; AUTHORITY SECTION: 233.168.192.in-addr.arpa. 600 IN NS ns2.enzhi.com. 233.168.192.in-addr.arpa. 600 IN NS ns.enzhi.com. ;; ADDITIONAL SECTION: ns.enzhi.com. 600 IN A 192.168.233.135 ns2.enzhi.com. 600 IN A 192.168.233.134 ;; Query time: 1 msec ;; SERVER:192.168.233.134#53(192.168.233.134) ;; WHEN: Thu Mar 24 12:44:58 2016 ;; MSG SIZE rcvd: 139
本文出自 “enzhi” 博客,转载请与作者联系!
标签:dns服务器
原文地址:http://enzhi.blog.51cto.com/11193298/1754678