主域名解析服務器腳本

#!/bin/bash
#dns腳本
#竇豔如
#2019-08-25
read -p "請輸入從服務器網址:" dou
read -p "請輸入主服務器網址:" yan
read -p "請輸入服務器名字:" ru
read -p "正向解析文件:" yun
read -p "反向解析文件:" ji
yum -y install bind &>/dev/null
if [ $? = 0 ]
        then
echo "以安裝完畢"
        else
echo "包以存在"
fi
cat << END > /etc/named.conf
options{
 
        directory       "/var/named";
};
zone "$ru" IN {
        type master;
        file "$yun";
        allow-transfer { $dou; };
};
zone "200.168.192.in-addr.arpa" IN {
        type master;
        file "$ji";
        allow-transfer { $dou; };
};
END
cat << END > /var/named/$yun
\$TTL 86400
@       IN      SOA     $ru. mail.dou.com. (
                        20190826
                        1D
                        1H
                        1W
                        1H
)
        NS              ns1.dou.com.
        NS              ns2.dou.com.
ns1     A               $yan
ns2     A               $dou
www     A               192.168.200.114
END
cat << END > /var/named/$ji
\$TTL 86400
@       IN      SOA     $ru. mail.dou.com. (
                        20190826
                        1D
                        1H
                        1W
                        1H
)
        NS              ns1.dou.com.
        NS              ns2.dou.com.
113     PTR             ns1.dou.com.
112     PTR             ns2.dou.com.
114     PTR             www.dou.com.
END
cat << END >> /etc/resolv.conf
nameserver $yan
nameserver $dou
END
cat << END >> /etc/hosts
$yan ns1.dou.com
$dou ns2.dou.com
END
systemctl start named systemctl enable named
相關文章
相關標籤/搜索