安装软件
yum -y install bind
修改从服务器主配置文件
vim /etc/named.conf
options {
listen-on port 53 { localhost; }; #此处改为localhost 侦听的地址 或者注释掉或者删掉
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";
allow-query { any; }; #此处改为any ,是允许所有主机来访问
allow-transfer {none;}; #从服务器 不允许任何主机抓取本机区域数据库信息
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.root.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 "." IN {
type hint;
file "named.ca"; #named.ca 是根地址
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
修改区域配置文件
vim /etc/named.rfc1912.zones
zone "hxg.com" IN { #域名与主服务器保持一致
type slave;
masters {192.168.3.102;}; #指明主服务器地址
file "slaves/hxg.com.zone"; #指明从服务器数据库文件存放位置
};
启动服务
systemctl start named
会自动从主服务器上同步数据库文件
修改主服务器主配置文件
修改为只允许从服务器抓取主服务器的区域数据库信息
vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
allow-query { any; };
allow-transfer {192.168.3.101;}; #只允许192.168.3.101能抓去主服务器的数据库信息
配置主服务器上的区域数据库文件
vim /var/named/hxg.com.zone
$TTL 1D
@ IN SOA master admin ( 51 2H 10M 1W 1D ) #要修改序列号,将50改为51
NS master
NS slave #增加从节点
master A 192.168.3.102
slave A 192.168.3.101 #绑定从节点
ap A 192.168.3.101
www CNAME ap
* CNAME web
@ A 192.168.3.101
app A 1.1.1.1
db A 2.2.2.2
标签:named,DNS,192.168,file,var,服务器,data,搭建
From: https://www.cnblogs.com/guangdelw/p/17300890.html