標籤:please domain master file
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
@insoa$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 "
@inns$head
$headina$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 "
$headina$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 "
@inmx$priority$head
$headina$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 "
$aliaseincname$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
shell指令碼之dns安裝配置