前言:
今天姐妹们对“centos主从dns”大概比较注重,你们都想要知道一些“centos主从dns”的相关内容。那么小编同时在网摘上收集了一些有关“centos主从dns””的相关资讯,希望看官们能喜欢,朋友们快快来了解一下吧!一:安装软件
yum -y install bind bind-chroot bind-libs bind-utils caching-nameserver
二:修改配置
1.编辑 /etc/named.conf
注释 //include "/etc/named.rfc1912.zones";
添加:include "/etc/named/named.ms-ledou.com.zones";
listen-on port 53 { 127.0.0.1; };
改为
listen-on port 53 { any; };
allow-query { localhost; };
改为:
allow-query { any; };
内部zone 标识为:ms-ledou.com
2.编辑zone文件
/etc/named/named.ms-ledou.com.zones
zone "ms-ledou.com" IN {
type master;
file "ledou_ms/ms-ledou.com.zone";
};
3.#配置检测是否正确
named-checkconf
4.#添加zone
cd /var/named
mkdir ledou_ms
vi ms-ledou.com.zone
$TTL 300
@ IN SOA @ rname.invalid. (
1 ; serial
1H ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.10.70
meng IN A 192.168.10.78
;gz mysql db-ms-ucenter-ms-player
pro-db00-04 IN A 10.30.80.220
pro-db05-09 IN A 10.30.80.225
;gz mysql db
pro-mdb-21 IN A 10.2.90.21
pro-mdb-40 IN A 10.2.90.40
pro-mdb-41 IN A 10.2.90.41
#注释使用分号 ;
#每次修改文件 serial值增加1,避免存在不生效
三:启动服务
需要修改 文件属主为 named
chown -R root.named /var/named/ledou_ms*
systemctl start named netstat -anput | grep named // 查看服务运行状态,UDP 53端口在监听
测试验证
vi /etc/resolv.conf //定义DNS服务器的IP地址
[root@dns1 ledou_ms]# cat /etc/resolv.conf
# Generated by NetworkManager
#search localdomain
nameserver 192.168.10.70
#yum install bind-utils -y //安装域名解析工具nslookup
验证正向解析
#ping 测试
#nslookup 测试
#dig 测试
dig @192.168.10.70 pro-mdb-41.ms-ledou.com
换机器测试
四:配置主从DNS
主:192.168.10.70
从:192.168.10.78
1.编辑zone文件,添加信息
/etc/named/named.ms-ledou.com.zones
zone "ms-ledou.com" IN {
type master;
file "ledou_ms/ms-ledou.com.zone";
allow-update { 192.168.10.78; }; // 允许更新从
also-notify { 192.168.10.78; }; //允许通知从
};
2.重启主named服务
systemctl restart named
systemctl status named
3.从DNS配置
类似主named,安装基础服务组件
5.编辑 /etc/named.conf
注释 //include "/etc/named.rfc1912.zones";
添加:include "/etc/named/named.ms-ledou.com.zones";
修改:
listen-on port 53 { 192.168.10.78; };
allow-query { any; };
内部zone 标识为:ms-ledou.com
2.编辑zone文件
/etc/named/named.ms-ledou.com.zones
zone "ms-ledou.com" IN {
type slave;
masters { 192.168.10.70; }; //指向主
file "slaves/ms-ledou.com.zone"; //文件存放地址
also-notify { 192.168.10.70; }; //配置主
};
3.#配置检测是否正确
named-checkconf
4.#不需要手动配置zone文件
5.启动named服务,检查zone文件是否生成
systemctl start named netstat -anput | grep named // 查看服务运行状态,UDP 53端口在监听
[root@dns2 slaves]# pwd
/var/named/slaves
[root@dns2 slaves]# ls
ms-ledou.com.zone
6.测试验证从DNS配置
dig @192.168.10.78 meng.ms-ledou.com
dig @192.168.10.78 pro-db05-09.ms-ledou.com
7.验证主从同步
修改主DNS记录值
/var/named/ledou_ms/ms-ledou.com.zone
#serial 加1
2 ; serial
#meng ns 从78 改成 79
meng IN A 192.168.10.79
#增加新记录
;gz redis
pro-rdb-22 IN A 10.2.90.22
主从DNS服务,重启named
systemctl restart named
验证:
dig @192.168.10.78 pro-rdb-22.ms-ledou.com|grep pro-rdb-22
dig @192.168.10.70 pro-rdb-22.ms-ledou.com|grep pro-rdb-22
dig @192.168.10.70 meng.ms-ledou.com|grep meng
dig @192.168.10.78 meng.ms-ledou.com|grep meng
#配置文件备份
dns1 到 dns2
在dns2 /slave 上配置
/etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 20
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[dns_config]
path = /data/dns_config
auth users = ledou00
read only = no
hosts allow = 10.0.0.0/8
#hosts deny = *
secrets file = /etc/rsyncd.pass
ignore errors = yes
#
/etc/rsyncd.pass
ledou00:###
chmod 600 /etc/rsyncd.pass
rsync --daemon
systemctl enable rsyncd
systemctl restart rsyncd
#计划任务
#add by shiye
0 */2 * * * cd /data/scripts/; /bin/bash backup_dns.sh >/dev/null 2>&1 &
dns1 上同步文件
vi /etc/rsyncd.pass (只保留密码)
###
chmod 600 /etc/rsyncd.pass
mkdir /data
tar zcPf Q_sh_ledou_dns_master_config_`date +%Y%m%d`.tgz /var/named /etc/named*
rsync -avzu --exclude='.svn/' --progress --password-file=/etc/rsyncd.pass /data/ledou_dns/ ledou00@192.168.10.78::dns_config
#
#!/bin/bash
#backup file
cd /data/backup
tar zcPf Q_sh_ledou_dns_master_config_`date +%Y%m%d`.tgz /var/named /etc/named* /data/scripts
#send file to dns slave
rsync -avzu --progress --password-file=/etc/rsyncd.pass /data/backup/ ledou00@10.5.90.9::dns_config
#DNS Web管理利器-NamedManager部署说明
wget
标签: #centos主从dns