我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

SHELL脚本之在Centos7上配置DNS主从服务器

服务器配置脚本

#!/bin/bash
#DNS解析主服务器脚本文件
#auto by cheng at 2019.10.9

#安装服务包
yum install bind -y

修改主配置文件
sed -i '/listen-on/s/127.0.0.1/192.168.102.131/' /etc/named.conf
sed -i '/allow-query/s/localhost/any/' /etc/named.conf

#修改区域配置文件
cat >>/etc/named.rfc1912.zones <<-EOF
zone "kgc.com." IN {
        type master;
        file "kgc.com.zone";
        allow-transfer { 192.168.102.159; };
};
EOF

#复制区域数据配置文件模板
cp -p /var/named/named.localhost /var/named/kgc.com.zone

#修改区域数据配置文件
sed -i '2s/@/kgc.com/2' /var/named/kgc.com.zone
sed -i '2s/rname.invalid./admin.kgc.com/' /var/named/kgc.com.zone
sed -i '8s/@/kgc.com/' /var/named/kgc.com.zone
sed -i '9s/::1/192.168.102.131/' /var/named/kgc.com.zone
sed -i '10d' /var/named/kgc.com.zone
cat >>/var/named/kgc.com.zone <<-EOF
IN      MX      10      mail.kgc.com
www     IN      A       192.168.100.99
ftp     IN      A       192.168.100.88
stmp    IN      CNAME   www
*       IN      A       8.8.8.8
EOF

#开启服务
systemctl start named

#关闭防火墙
systemctl stop firewalld.service
setenforce 0

#修改dns解析地址配置文件
echo "nameserver 192.168.102.131" > /etc/resolv.conf

从服务器配置脚本

#!/bin/bash
#DNS解析从服务器脚本文件
#auto by cheng at 2019.10.9

#安装服务包
yum install bind -y

#修改主配置文件
sed -i '/listen-on/s/127.0.0.1/192.168.102.159/' /etc/named.conf
sed -i '/allow-query/s/localhost/any/' /etc/named.conf

#修改区域配置文件
cat >>/etc/named.rfc1912.zones <<-EOF
zone "kgc.com." IN {
        type slave;
        file "slaves/kgc.com.zone";
        masters { 192.168.102.131; };
};
EOF

#开启服务
systemctl start named

#关闭防火墙
systemctl stop firewalld.service
setenforce 0

#修改dns解析地址配置文件
echo "nameserver 192.168.102.159" > /etc/resolv.conf

本文名称:SHELL脚本之在Centos7上配置DNS主从服务器
文章网址:http://shouzuofang.com/article/jiehjg.html

其他资讯