#!/bin/bash
firwalld_stop(){
systemctl stop firewalld
setenforce 0
}
yum_install(){
yum install bind bind-chroot bind-utils -y
}
sed_change(){
sed -i '13s/127.0.0.1/any/' /etc/named.conf
sed -i '21s/localhost/any/' /etc/named.conf
}
edit_named_conf(){
cat >>/etc/named.conf<
zone "wg007.com" IN {
type master;
file "wg007.com.zone";
allow-update { none; };
allow-transfer { 172.18.47.112; };
notify yes;
also-notify { 172.18.47.112; };
};
eof
}
edit_zone(){
cat >>/var/named/wg007.com.zone<
$TTL 86400
@ IN SOA wg007.com. admin.wg007.com. (
20200107 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS admin.wg007.com.
admin IN A 172.18.47.110
www IN A 172.18.47.110
app IN A 172.18.47.110
ppp IN A 172.18.47.110
ftp IN CNAME www.wg007.com
eof
}
server_restart(){
systemctl restart named
}
#############################主dns服务器
firwalld_stop
rpm -qa |grep bind
if [ $? -ne 0 ]; then
yum_install
fi
sed_change
cat /etc/named.conf|grep -w "wg007"
if [ $? -ne 0 ]; then
edit_named_conf
fi
if [ ! -f /var/named/wg007.com.zone ]; then
edit_zone
fi
server_restart
#############################从dns服务器
ssh root@172.18.47.112 "
yum install bind bind-chroot bind-utils -y
sed -i '13s/127.0.0.1/any/' /etc/named.conf
sed -i '21s/localhost/any/' /etc/named.conf
cat >>/etc/named.conf<
zone \"wg007.com\" IN {
type slave;
file \"slaves.wg007.com.zone\";
masters { 172.18.47.110; };
};
eof
systemctl restart named
"