码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本之dns安装配置

时间:2014-11-27 18:58:56      阅读:223      评论:0      收藏:0      [点我收藏+]

标签: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

@ 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


shell脚本之dns安装配置

标签:please   domain   master   file   

原文地址:http://mengwumian.blog.51cto.com/9562947/1583120

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!