全部博文(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!!!"