shell脚本之dns安装配置

conf="/var/named/chroot/etc/named.conf"

datadir="/var/named/chroot/var/named"

rpm -q bind &> /dev/null

if [ $? -ne 0 ];then

yum -y install bind bind-chroot caching*

echo "

options {

directory \"/var/named\";

};

" > $conf

fi

read -p "please input domain:" domain

grep $domain $conf &> /dev/null

if [ $? -ne 0 ];then

echo "

zone \"$domain\" in {

type master;

file \"$domain\";

};

" >> $conf

echo "

\$ttl 86400

@ in soa $domain. root.$domain. (

2014010101

3h

15m

1w

1d

)

" > $datadir/$domain

fi


while true

do

read -p "please type of record:(ns/a/mx/cname)" type

case $type in

ns)

read -p "head of FQDN:" head

read -p "ip address:" ip

read -p "Are you sure?(yes/no)" yn

if [ $yn != yes ];then

continue

fi


echo "

@ in ns $head

$head in a $ip

" >> $datadir/$domain

;;

a)

read -p "head of FQDN:" head

read -p "ip address:" ip

read -p "Are you sure?(yes/no)" yn

if [ $yn != yes ];then

continue

fi

echo "

$head in a $ip

" >> $datadir/$domain

;;

mx)

read -p "head of FQDN:" head

read -p "ip address:" ip

read -p "priority:" priority

read -p "Are you sure?(yes/no)" yn

if [ $yn != yes ];then

continue

fi

echo "

@ in mx $priority $head

$head in a $ip

" >> $datadir/$domain


;;

cname)

read -p "aliase of FQDN:" aliase

read -p "hostname:" hostname

read -p "Are you sure?(yes/no)" yn

if [ $yn != yes ];then

continue

fi

echo "

$aliase in cname $hostname

" >> $datadir/$domain

;;

*)

echo "usage: type of record (ns/a/mx/cname)"

esac

read -p "continue to do?(yes/no)" yn

if [ $yn != yes ];then

break

fi

done

service named restart


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。