Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22991
  • 博文数量: 6
  • 博客积分: 172
  • 博客等级: 入伍新兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 01:08
文章分类

全部博文(6)

文章存档

2011年(6)

我的朋友

分类: Python/Ruby

2011-03-27 12:09:40

#!/bin/bash
yum -y install bind  (安装DNS服务,如果没有yum源,可以使用rpm安装)    
yum -y install caching-nameserver
read -p "Please input your domainname:" DOMAIN

read -p "Please input your network:" NETWORK

read -p  "Please input your IP address:" IP

cat >> /etc/named.conf << EOF
options {
        directory "/var/named";
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
};

zone "$DOMAIN" IN {
        type master;
        file "$DOMAIN.zone";
};

zone "$NETWORK.in-addr.arpa" IN {
        type master;
        file "$NETWORK.zone";
};
EOF
                 
echo "OK,/etc/named.conf is created!!! "

cat >> /var/named/$DOMAIN.zone << EOF
\$TTL 86400
\$ORIGIN $DOMAIN.
@       IN      SOA     $DOMAIN.        root.$DOMAIN.   (
                                        `date +%Y%m%d`01
                                        5H
                                        10M
                                        7D
                                        1D   )
           IN      NS      ns
           IN      MX 10   mail
ns        IN      A       $IP
mail     IN      A       $IP
www   IN      A       $IP
EOF

END=`echo $IP |cut -d"." -f4`                
cat >> /var/named/$NETWORK.zone << EOF
\$TTL 86400
@       IN      SOA     $DOMAIN.        root.$DOMAIN.   (
                                        `date +%Y%m%d`01
                                        5H
                                        10M
                                        7D
                                        1D   )
             IN           NS          ns.$DOMAIN.
$END   IN      PTR     ns.$DOMAIN.
$END   IN      PTR     mail.$DOMAIN.
$END   IN      PTR     .
EOF

chown :named  /etc/named.conf /var/named/$DOMAIN.zone /var/named/$NETWORK.zone

echo "Ok,/var/named/$DOMAIN.zone , /var/named/$NETWORK.zone are created!!!"

echo "Good,the job is finished!!!"

阅读(813) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~