BIND 主从配置

环境:
master:172.31.182.144
slave:172.31.182.147

一、安装
yum install bind bind-chroot  -y

(源码包:https://downloads.isc.org/isc/bind9/9.14.8/bind-9.14.8.tar.gz)

二、master配置

[root@master named]# cat /etc/named.conf |grep -Ev "//|^$"
options {
listen-on port 53 { 172.31.182.144; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "adfile.wifi8.com" {
type master;
file "adfile.wifi8.com.hosts";
allow-transfer {172.31.182.147;};
notify yes;
also-notify { 172.31.182.147; }; //指定slave server的IP位址
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

zone文件:

[root@master named]# cat /var/named/adfile.wifi8.com.hosts
$TTL 180
@ IN SOA ns1.test.com. root.adfile.wifi8.com. ( ;
22190928 ; serial
10S ; refresh
1H ; retry
1M ; expire
44H ) ; minimum
IN NS ns1.test.com.
IN NS ns2.test.com.
ns1 IN A 172.31.182.144
ns2 IN A 172.31.182.147
adfile.wifi8.com. IN A 10.254.33.32
adfile.wifi8.com. IN A 10.254.33.34

各参数解析:http://dns-learning.twnic.net.tw/bind/intro6.html

启动:
systemctl  restart  named.service

三、slave配置

[root@node02 named]# cat /etc/named.conf |grep -Ev "//|^$"
options {
listen-on port 53 { 172.31.182.147; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "adfile.wifi8.com" {
type slave;
file "adfile.wifi8.com.hosts";
masters { 172.31.182.144; };
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

启动后自动同步master解析配置:
systemctl  restart  named.service

添加域名脚本:

#################master:#################
#!/bin/bash
read -p "Please enter the domain name you need to add:" DOMAIN
read -p "Please enter the domain name corresponding to the IP record:" IP
HOSTS_DIR=/mnt/sscp/data/named/hosts
NAMED_CONFIG_DIR=/mnt/sscp/data/named/conf/named.conf
#Create domain record file
cat >${HOSTS_DIR}/${DOMAIN}.hosts<<EOF
\$TTL 180
@ IN SOA ns1.sscp.mtr.com. root.${DOMAIN}. ( ;
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
44H ) ; minimum
IN NS ns1.sscp.mtr.com.
IN NS ns2.sscp.mtr.com.
ns1 IN A 128.164.250.26
ns2 IN A 128.164.250.27
${DOMAIN}. IN A ${IP}
EOF
#Add named config
cat >>${NAMED_CONFIG_DIR}<<EOF
zone "${DOMAIN}" IN{
type master;
file "${DOMAIN}.hosts";
allow-transfer {128.164.250.27;};
};
EOF
# Checkconf named config
/mnt/sscp/app/named/sbin/named-checkconf
#Restart named server
/mnt/sscp/app/named/sbin/rndc -s 127.0.0.1 reload
if [ $? = 0 ];then
echo "Added successfully!!"
else
echo "Add failed!! Please check"
fi #################slave:#################
#!/bin/bash
read -p "Please enter the domain name you need to add:" DOMAIN
HOSTS_DIR=/mnt/sscp/data/named/hosts
NAMED_CONFIG_DIR=/mnt/sscp/data/named/conf/named.conf
#Add named config
cat >>${NAMED_CONFIG_DIR}<<EOF
zone "${DOMAIN}" IN{
type slave;
file "${DOMAIN}.hosts";
masters { 128.164.250.26; };
};
EOF
# Checkconf named config
/mnt/sscp/app/named/sbin/named-checkconf
#Restart named server
/mnt/sscp/app/named/sbin/rndc -s 127.0.0.1 reload
if [ $? = 0 ];then
echo "Added successfully!!"
else
echo "Add failed!! Please check"
fi

踩坑:
1、最后需要在主DNS服务器上的/var/named/ZONE_NAME.zone 文件里添加将该从服务的NS记录;
2、同时若想要实现主从服务器的数据同步,在修改好主服务器的/var/named/ZONE_NAME.zone 文件时,必须将该文件里的 序列号 增大才行,增大并保存退出后,主服务器会自动向从服务器推送(push)修改后的文件内容;

BIND 主从配置的更多相关文章

  1. BIND的进程一:DNS简单配置与的主从配置

    DNS的简单配置和DNS的主从配置   摘要:DNS(Domain-Name Server) ,DNS的服务起到的作用就是名称解析,在网络通讯来说计算机与计算机是通过IP地址相互通信的, 当是IP地址 ...

  2. Ubuntu+Redis主从配置

    软件环境: OS:ubuntu-12.04-desktop-amd64 Redis:redis-2.8.13.tar.gz TCL:tcl8.6.2-src.tar.gz VMware:vmware ...

  3. redis 主从配置和集群配置

    主从配置 |  集群配置 redis主从 主从配置原因: 1.到达读写分离,读的操作和写操作比例10 : 1读数据频繁,写数据次数少,这样可以配置1个master数据库用来写数据,配置多个slave从 ...

  4. Redis入门及主从配置

    1.Redis入门简介 Redis是一个开源的使用ANSI C语音编写.支持网络.可基于内存亦可持久化的日志型,Key-Value数据库.支持存储的value类型包括 string(字符串).list ...

  5. python中发布订阅和主从配置

    发布订阅 发布者不是计划发送消息给特定的接收者(订阅者),而是发布的消息分到不同的频道,不需要知道什么样的订阅者订阅 订阅者对一个或多个频道感兴趣,只需接收感兴趣的消息,不需要知道什么样的发布者发布的 ...

  6. CentO7 安装 redis, 主从配置,Sentinel集群故障转移切换

        一.Redis的安装(前提是已经安装了EPEL)   安装redis: yum -y install redis 启动/停止/重启 Redis 启动服务: systemctl start re ...

  7. BIND简易教程(2):BIND视图配置

    目录:BIND简易教程(1):安装及基本配置BIND简易教程(2):BIND视图配置(本篇)BIND简易教程(3):DNSSec配置 上文书说到,我们把aaa.apple.tree解析到192.168 ...

  8. Redis主从配置与数据备份还原

    一.主从配置: 1.下载: wget http://download.redis.io/releases/redis-4.0.9.tar.gz tar xzf redis-4.0.9.tar.gz c ...

  9. Redis学习总结(四)--Redis主从配置

    在分布式系统架构设计中高可用是必须考虑的因素之一.高可用通常是指,通过设计减少系统不能提供服务的时间.而单点是系统高可用的最大的败笔,如果单点出现问题的话,那么整个服务就不能使用了,所以应该尽量在系统 ...

随机推荐

  1. 006-nginx.conf详解-error_page 使用

    一.概述 nginx指令error_page的作用是当发生错误的时候能够显示一个预定义的uri 1.1.使用步骤 更改nginx.conf在http定义区域加入: proxy_intercept_er ...

  2. matlab学习笔记13_1 函数返回值

    一起来学matlab-matlab学习笔记13函数 13_1 函数返回值 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 https://blog.csdn.net/qq_36556 ...

  3. 【451】python 同一行打印进度条

    参考:Python3 Print 同一行打印显示进度条效果 参考:\r\n, \r and \n what is the difference between them? [duplicate] 参考 ...

  4. jstree: 获得根节点,checkbox事件处理

    $.jstree.defaults.core.themes.responsive = true; $.jstree.defaults.checkbox.three_state = false;// 如 ...

  5. System.Threading.Timer定时器使用注意事项

    1.定时器不要直接在方法里面定义和赋值,因为方法执行完,方法体内的变量会被GC回收. 有时候我们将timer定义在了方法里面,然后看到timer被执行了几次之后才失效,原因就是GC不一定会立即回收. ...

  6. linux减少服务器带宽的方法

    linux减少服务器带宽的方法用百度静态资源公共库http://cdn.code.baidu.com/ 不仅可以不使用服务器流量 而且还有cdn加速比方说http://apps.bdimg.com/l ...

  7. PHP- 如何在终端输出带颜色的字体?

    转自: http://www.neatstudio.com/show-2568-1.shtml 终端显示颜色,在以前的想法当中,都是因为有了.profile的配色方案.而我一般也都是 采用默认的(sn ...

  8. 解决netty客户端接收报文不完整的情况

    逻辑就是在处理handler前加入一个处理符,然后 channelReadComplete这个事件进行处理.同时注意客服端的配置: public void connect(String addr, i ...

  9. Codeforces Round #604 (Div. 2) (题解)

    A. Beautiful String (暴力) 题目链接 题目大意: 给定一个字符串,只有 \(?a\ b\ c\ ?\) ,问是否存在一种将所有的 \(?\) 替换成 \(a\ b\ c\) ,使 ...

  10. 大数据之路【第十四篇】:数据挖掘--推荐算法(Mahout工具)

    数据挖掘---推荐算法(Mahout工具) 一.简介 Apache顶级项目(2010.4) Hadoop上的开源机器学习库 可伸缩扩展的 Java库 推荐引擎(协同过滤).聚类和分类 二.机器学习介绍 ...