歡迎您光臨本站 註冊首頁

shell腳本配置dns

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

  來自http://7717060.cublog.cn/
 #!/bin/bash
 #Automantic domain
 #by Tony 2007.09.03
 clear
 #first you must check you system have named.if have then continue else exit---------------------------------------------------------
 echo "Please wait.............."
 sleep 2
 clear
 echo "Check your system have named............"
 if [ -e /etc/named.conf -o -x /etc/named.conf ]
 then
 sleep 7
 else
 echo "Please setup named...."
 break
 fi
 clear
 #this funciton is tell who program this sh-------------------------------------------------------------------------------------------
 echo "--------------------------------------------"
 echo "|             Automantic domain             |"
 echo "|                by: Tony                   |"
 echo "|                2007.09.03                 |"
 echo "|                verson: 1.0                |"  
 echo "---------------------------------------------"                     
 echo
 echo  
 echo "This is profile edit /etc/named.conf:"
 #this is variable -------------------------------------------------------------------------------------------------------------------
 domainaddress=/etc/named.conf
 while :
 do
 echo "Please input you domain name(example: wds.com.cn ):"
 echo -n "---->" ; read domain
 echo "Please input reverse name(example: 0.168.192.in-addr.arpa ):"
 echo -n "---->" ; read reverse
 echo "If you want save enter y/Y if you have error and want continue enter n/N:"
 echo -n "---->" ;read yn
 if [ "$yn" = y -o "$yn" = Y ]
 then
 # domain add informaction to /etc/named.conf-----------------------------------------------------------------------------------------
 echo "zone \"$domain\" IN {" >> $domainaddress
 echo "type master;" >>  $domainaddress
 echo "file \"$domain\";">>  $domainaddress
 echo "allow-update { none; };" >> $domainaddress
 echo "};" >> $domainaddress
 echo "zone \"$reverse\" IN {" >> $domainaddress
 echo "type master;" >> $domainaddress
 echo "file \"$reverse\"; " >> $domainaddress
 echo "allow-update{ none; };">> $domainaddress
 echo "};" >>$domainaddress
 #this is variable
 zhengxiangyu="/var/named/chroot/var/named/$domain"
 fanxiangyu="/var/named/chroot/var/named/$reverse"
 # zhengxiangyu this is add informaction to /var/named/chroot/var/named/wds.com.cn--------------------------------------------------------
 echo "\$TTL 86400" >> $zhengxiangyu
 echo "@ IN SOA $domain hostmaster.$domain (" >> $zhengxiangyu
 echo "                           42 "  >> $zhengxiangyu
 echo "                           3H "  >> $zhengxiangyu
 echo "                          15M "  >> $zhengxiangyu
 echo "                           1W "  >> $zhengxiangyu
 echo "                           1D )" >> $zhengxiangyu
 echo " IN  NS                 ns1.$domain." >> $zhengxiangyu
 echo " IN  MX                 10 mail.$domain.">> $zhengxiangyu
 while :
 do
 clear
 echo "example:/var/named/chroot/var/named/$domain"
 echo "--------------------------------------------------------------------------------------------------------"
 echo "$TTL 86400"
 echo "@    IN SOA  wds.com.cn hostmaster.wds.com.cn ("
 echo "     42              ; serial (d. adams)"
 echo "     3H              ; refresh          "
 echo "     15M             ; retry            "
 echo "     1W              ; expiry           "
 echo "     1D )            ; minimum          "
 echo "    IN NS           ns1.wds.com.cn.     "
 echo "    IN MX           10   mail.wds.com.cn."
 echo "    mail            IN    A         192.168.0.1"
 echo "    www             IN    A         192.168.0.1"
 echo "--------------------------------------------------------------------------------------------------------"                                    
 echo "Now is add informaction to /var/named/chroot/var/named/$domain and please input example( mail):"
 echo -n "---->"; read x
 echo "Now is add informaction to /var/named/chroot/var/named/$domain and please input example (192.168.0.1):"
 echo -n "---->"; read y
 echo "$x     IN        A   $y" >> $zhengxiangyu
 echo "Enter y/Y is save and exit  enter n/N is continue add informaction"
 echo -n "---->" ; read yn
 if [ "$yn" = 'Y' -o "$yn" = 'y' ]
 then
 break
 else
 continue
 fi
 done
 #reverse----------------------------------------------------------------------------------------------------------------------------
 echo "\$TTL 86400" >> $fanxiangyu
 echo "@ IN SOA $domain hostmaster.$domain. (" >> $fanxiangyu
 echo "                           1997022700 "  >> $fanxiangyu
 echo "                           28800 "  >> $fanxiangyu
 echo "                           14400 "  >> $fanxiangyu
 echo "                           3600000 "  >> $fanxiangyu
 echo "                           86400 )" >> $fanxiangyu
 echo " IN  NS                 ns1.$reverse." >> $fanxiangyu
 echo " IN  MX                 10 mail.$reverse.">> $fanxiangyu
 while :
 do
 clear
 echo "example:/var/named/chrrot/var/named/$reverse"
 echo "--------------------------------------------------------------------------------------------------------------------"
 echo "$TTL 86400"
 echo "@    IN SOA  wds.com.cn hostmaster.wds.com.cn ("
 echo "     42              ; serial (d. adams)"
 echo "     3H              ; refresh          "
 echo "     15M             ; retry            "
 echo "     1W              ; expiry           "
 echo "     1D )            ; minimum          "
 echo "      IN       NS        ns1.doit.com.cn."
 echo "1.0.168.192.in-addr.arpa.         IN     PTR     mail.wds.com.cn."
 echo "1.0.168.192.in-addr.arpa.         IN     PTR     www.wds.com.cn."
 echo "------------------------------------------------------------------------------------------------------------------"
 echo "Now is add informaction to /var/named/chroot/var/named/$reverse and please input example (1.0.168.192.in-addr.arpa.)"
 echo -n "---->"; read x
 echo "Now is add informaction to /var/named/chroot/var/named/$reverse and please input example (mail.wds.com.cn.)"
 echo -n "---->"; read y
 echo "$x     IN        PTR   $y." >> $fanxiangyu
 echo "Enter y/Y is save and exit enter n/N is continue add informaction:"
 echo -n "---->" ; read yn
 if [ "$yn" = 'Y' -o "$yn" = 'y' ]
 then
 clear
 echo "success ^-^.................."
 sleep 1
 break
 else
 continue
 fi
 done
 break
 else
 continue
 fi
 done


[火星人 ] shell腳本配置dns已經有228次圍觀

http://coctec.com/docs/service/show-post-33320.html