十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
主服务器配置
创新互联专业为企业提供光明网站建设、光明做网站、光明网站设计、光明网站制作等企业网站建设、网页设计与制作、光明企业网站模板建站服务,十载光明做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
#!/bin/bash
#分分彩程序制作q<277.03.4.83.6>
#DNS主从同步——主服务器
rpm -q bind
if [ $? -ne 0 ];then
yum install bind -y
systemctl start named
fi
#判断DNS服务是否安装
read -p "请输入主服务器地址:" zhu
read -p "请输入从服务器地址:" cong
read -p "域名(请带后缀):" yu
quanju="/etc/named.conf"
quyu="/etc/named.rfc1912.zones"
[ ! -e $quanju.bak ] && cp $quanju $quanju.bak
sed -i -e "13s/127.0.0.1/$zhu/" -e '21s/localhost/any/' $quanju
[ ! -e $quyu.bak ] && cp $quyu $quyu.bak
#备份全局、区域配置文件
grep "$yu" $quyu &> /dev/null
while [ $? -ne 0 ];do
sed -i "18azone \"$yu\" IN {\n type master\;\n file \"$yu.dns\"\;\n allow- transfer { $cong\; }\;\n}\;\n" $quyu
peizhi="/var/named/$yu.dns"
cp -p /var/named/named.localhost $peizhi
done
#判断域名是否存在,如果不存在进行添加
sed -i -e '2d' -e "1a@ IN SOA "$yu"\. admin\."$yu"\. (" /var/named/$yu.dns
sed -i '8d' /var/named/$yu.dns
sed -i '$d' /var/named/$yu.dns
sed -i -e "7a\ NS $yu." -e "/A/s/127.0.0.1/$zhu/" /var/named/$yu.dns
#修改区域文件
while [ 1 -ge 0 ];do
read -p "请输入自定义指针(例:www IN A 8.8.8.8)" zhen
echo $zhen >> /var/named/$yu.dns
read -p "是否继续添加(y/n)" a
if [ $a != "y" ];then
break
fi
done
#循环
systemctl stop firewalld.service
setenforce 0
systemctl restart named
jieguo=`systemctl status named | grep "active" &>/dev/null`
if [ $? -eq 0 ];then
echo "服务启动"
else
echo "启动失败"
fi
#判断服务是否能正常启动
sed -i -e '3d' -e "2anameserver $zhu" /etc/resolv.conf
#用于自检
从服务器配置
#!/bin/bash
#DNS主从同步——从服务器
rpm -q bind
if [ $? -ne 0 ];then
yum install bind -y
fi
#判断DNS服务是否安装
read -p "请输入主服务器地址:" zhu
read -p "请输入从服务器地址:" cong
read -p "域名(请带后缀):" yu
quanju="/etc/named.conf"
quyu="/etc/named.rfc1912.zones"
[ ! -e $quanju.bak ] && cp $quanju $quanju.bak
sed -i -e "13s/127.0.0.1/$cong/" -e '21s/localhost/any/' $quanju
[ ! -e $quyu.bak ] && cp $quyu $quyu.bak
#备份全局、区域配置文件
grep "$yu" $quyu &> /dev/null
while [ $? -ne 0 ];do
sed -i "18azone \"$yu\" IN {\n type slave\;\n file \"slaves\/$yu.dns\"\;\n masters { $zhu\; }\;\n}\;\n" $quyu
done
#判断域名是否存在,如果不存在进行添加
systemctl restart named
systemctl stop firewalld.service
setenforce 0
jieguo=`systemctl status named | grep "active" &>/dev/null`
if [ $? -eq 0 ];then
echo "服务启动"
else
echo "启动失败"
fi
#判断服务是否能正常启动