免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2341 | 回复: 2
打印 上一主题 下一主题

[DNS] [原创]shell配置dns [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-02 10:12 |只看该作者 |倒序浏览
#!/bin/bash
#Automantic domain
#by Tony 2007.09.03
#来自:http://blog.chinaunix.net/u1/40306/showart_383397.html
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

[ 本帖最后由 7717060 于 2008-2-5 12:11 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-02-14 23:55 |只看该作者
没人顶那,我捧个场

论坛徽章:
0
3 [报告]
发表于 2008-02-18 11:05 |只看该作者
here document....
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP