!/bin/bash
read -p "Please input your domain name:" DOMAIN
read -p "Please input your IPaddress:" NET
hostname www.$DOMAIN
yum install bind caching-nameserver -y
a=echo $NET |cut -d"." -f1
b=echo $NET |cut -d"." -f2
c=echo $NET |cut -d"." -f3
d=echo $NET |cut -d"." -f4
cat > /etc/named.conf << "EOF"
options {
directory "/var/named" ;
};
zone "." IN {
type hint;
file "named.ca";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
};
zone "DOMAIN" IN {
type master;
file "DOMAIN.zone";
};
zone "FAN.in-addr.arpa" IN {
type master;
file "PTR.arpa";
};
EOF
sed -i 's/DOMAIN/'c.a'/g' /etc/named.conf
sed -i 's/PTR/'b.$c'/g' /etc/named.conf
cat > /var/named/TTL 36400
@ IN SOA DOMAIN. admin.DOMAIN. (
2011024
3H
15M
1W
1D)
EOF
echo "@ IN NS www.DOMAIN.zone
echo " IN MX 10 mail.DOMAIN.zone
echo "www IN A DOMAIN.zone
echo "mail IN A DOMAIN.zone
sed -i 's/DOMAIN/'DOMAIN.zone
cat > /var/named/b.TTL 36400
@ SOA DOMAIN. admin.DOMAIN. (
20110224
3H
15M
1W
1D)
EOF
echo "@ IN NS www.a.c.arpa
echo "DOMAIN." >> /var/named/b.d IN PTR www.a.c.arpa
sed -i 's/DOMAIN/'a.c.arpa
echo "nameserver NET
chown named /var/named/*.arpa
chown named /etc/named.conf
chown named /var/named/$DOMAIN.zone
service named restart
网友评论