Linux-DNS服务器:BIND区域传送
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux-DNS服务器:BIND区域传送相关的知识,希望对你有一定的参考价值。
1. BIND的区域传送(主从同步)
当一个域内主DNS宕机或者压力过高时就需要在添加一台DNS服务器用来顶替主DNS或者缓解主DNS的压力。
主机规划:
角色 | IP地址 | 主机名 |
DNS-MASTER | 192.168.233.135 | dns_master |
DNS-SLAVE | 192.168.233.134 | dns_slave |
3.1 配置区域传送的步骤
向区域中添加从服务器的关键两步步:
(在上级获得授权)
在区域数据文件中为从服务器添加一条NS记录和对应的A记录;
3.2 安装从DNS服务器
[[email protected]_slave ~]# yum -y install bind [[email protected]_slave ~]# mv /etc/named.conf/etc/named.conf.ori [[email protected]_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";
3.3 配置主服务器主配置文件授权从服务器
#在主服务器的zone中添加一行allow-transfer{ SLAVE_SERVER_IP;};允许某个从服务器可以复制区域数据文件。
[[email protected]_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; }; };
3.4修改主服务器的区域文件添加从服务器的ns记录
[[email protected]_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
#修改反向区域数据文件
[[email protected]_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服务
[[email protected]_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 [[email protected]_master named]#/etc/init.d/named reload Reloading named: [ OK ]
3.5 启动dns-slave的named服务
[[email protected]_slave ~]# /etc/init.d/namedconfigtest #语法检查 zone localhost/IN: loaded serial 0 zone 1.0.0.127.in-addr.arpa/IN: loadedserial 0 [[email protected]_slave ~]# /etc/init.d/namedstart #启动named Generating /etc/rndc.key: [ OK ] Starting named: [ OK ] #检查区域数据文件是否成功复制过来 [[email protected]_slave ~]# cd/var/named/slaves/ [[email protected]_slave slaves]# ls 192.168.233.zone enzhi.com.zone
3.6 使用dig命令测试slave能否解析
[[email protected]_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 [email protected] ;; 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
#反向解析
[[email protected]_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 [email protected] ;; 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” 博客,转载请与作者联系!
以上是关于Linux-DNS服务器:BIND区域传送的主要内容,如果未能解决你的问题,请参考以下文章
Linux-dns基础知识和BIND的简单配置-2(正向解析和反向解析)