架构师成长之路-DNS服务器搭建(部署主从DNS)

点击返回架构师成长之路

架构师成长之路-DNS服务器搭建(部署主从DNS)

 部署主DNS : 点击
 部署从DNS : 如下步骤

1.与主DNS一样,安装bind

yum -y install bind-utils bind bind-devel bind-chroot bind-libs

2.与主DNS一样,编辑/etc/named.conf

options {
  version "1.1.1";
  listen-on port 53 {any;};  #表示使用53端口
  directory "/var/named/chroot/etc/";#用来指定zone(A记录/MX记录等)文件配置路径,注意chroot加强安全性
  pid-file "/var/named/chroot/var/run/named/named.pid"; #当服务起来的时候,pid的位置
  allow-query { any; };#允许解析访问的权限,可以是ip地址或ip段
  Dump-file "/var/named/chroot/var/log/binddump.db";
  Statistics-file "/var/named/chroot/var/log/named_stats";#可以看到解析数量/成功率等,用于监控
  zone-statistics yes;# 配置yes,才能写入
  memstatistics-file "log/mem_stats";
  empty-zones-enable no; #不允许配置zone,却没有记录
  forwarders {202.106.196.115;8.8.8.8; };#外部转发至以下IP地址
};

key "rndc-key" { # 生成rndc控制命令的key文件,rndc与bind之间使用md5认证
        algorithm hmac-md5;
        secret "Eqw4hClGExUWeDkKBX/pBg==";
};

controls {
       inet 127.0.0.1 port 953  #连接的实际是953,不是53
               allow { 127.0.0.1; } keys { "rndc-key"; };
 };

logging {  #指定日志记录分类和他们的目标位置
  channel warning {
    file "/var/named/chroot/var/log/dns_warning" versions 10 size 10m;#日志轮转10次,每次10M 
    severity warning;
    print-category yes;
    print-severity yes;
    print-time yes;
  };
  channel general_dns {
    file "/var/named/chroot/var/log/dns_log" versions 10 size 100m;#日志轮转10次,每次100M
    severity info;
    print-category yes;
    print-severity yes;
    print-time yes;
  };
  category default {
    warning;
  };
  category queries {
    general_dns;
  };
};

include "/var/named/chroot/etc/view.conf";  # viem简单实现智能DNS功能

3.与主DNS一样,编辑/etc/rndc.key

key "rndc-key" {
        algorithm hmac-md5;
        secret "Eqw4hClGExUWeDkKBX/pBg==";
};

4.与主DNS一样,编辑/etc/rndc.conf  

key "rndc-key" {
        algorithm hmac-md5;
        secret "Eqw4hClGExUWeDkKBX/pBg==";
};

options {
        default-key "rndc-key";
        default-server 127.0.0.1;
        default-port 953;
};

5.编辑/var/named/chroot/etc/view.conf

view "SlaveView1" {
             allow-transfer {
                #dns-ip-list; 
        };      
             notify  yes;
             also-notify {
                #dns-ip-list; 
        };
       
#  ixfr-from-differences yes;
zone "carlos.com" {
        type    slave;  #master:表示定义的是主域名服务器,slave :表示定义的是辅助域名服务器 
        masters {192.168.56.13;}
        file    "carlos.com.zone"; 
        };
  };

6.修改目录权限  

cd /var && chown -R named.named named/ #修改目录权限
/etc/init.d/named start  #启动
chkconfig named on   #加开机启动

回到主DNS,master设备,执行rndc reload
回到从DNS,在/etc/chroot/etc 下面是否生成slave.carlos.com.zone文件,若有表示已经自动同步过来。  

......

posted on 2019-01-15 23:29  CARLOS_KONG  阅读(617)  评论(0编辑  收藏  举报

导航