shell脚本一键部署DNS正向解析

shell脚本一键部署DNS正向解析

#!/bin/bash
cd /etc/yum.repos.d
if [ ! -e local.repo ]
then
mkdir repos.bak
mv *.repo repos.bak
echo '[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1' > local.repo
fi
mount /dev/sr0 /mnt
yum -y install bind
sed -i -e "13 s/127.0.0.1/any/" -e "14 s/^/#/" -e "21 s/localhost/any/" /etc/named.conf
echo "zone \"kgc.com\" IN {
    
    
        type master;
        file \"kgc.com.zone\";
        allow-update {
    
     none; };
};" >> /etc/named.rfc1912.zones
cp -p /var/named/named.localhost /var/named/kgc.com.zone
 sed -i '2 s/@/kgc.com./2' /var/named/kgc.com.zone
  sed -i '8 s/@/kgc.com./1' /var/named/kgc.com.zone
  sed -i '9 s/127.0.0.1/192.168.100.30/1' /var/named/kgc.com.zone
  sed -i '10d' /var/named/kgc.com.zone
  sed -i '9a www  IN  A  192.168.100.30' /var/named/kgc.com.zone
sed -i '2c nameserver 192.168.100.30' /etc/resolv.conf
systemctl stop firewalld.service
setenforce 0
systemctl start named

在这里插入图片描述
测试结果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Desire_cure_/article/details/114825841

相关文章