Shell脚本——DNS自动部署详细说明查看:
(一)跟我一起玩linux网络服务:DNS服务——BIND(/etc/named.conf、/var/named)设置实现和解释
1 #! /bin/bash 2 ip="10.10.10" 3 RIP="10.10.10" 4 DN="gr.org" 5 Name="10.10.10.10" 6 7 cat >> /etc/named.conf << +END+ 8 zone "$DN." IN { 9 type master;10 file "gr.org.db";11 };12 zone "$RIP.in-addr.arpa" IN{13 type master;14 file "$IP.db";15 };16 +END+17 cat > /var/named/$DN.db <<+END+18 \$TTL 8640019 @ IN SOA ns.$DN. root.$DN. (20 20150317 6H 30M 1W 15M)21 IN NS ns.$DN.22 IN MX 10 mail.$DN.23 bbs IN CNAME www.$DN.24 ns IN A $IP.1025 www IN A $IP.1026 mail IN A $IP.1127 +END+28 cat > /var/named/$IP.db <<+END+29 \$TTL 8640030 @ IN SOA ns.$DN. root.$DN.(31 20150317 6H 30M 1W 15M)32 IN NS ns.$DN.33 10 IN PTR ns.$DN.34 10 IN PTR www.$DN.35 11 IN PTR mail.$DN.36 +END+37 cat > /etc/resolv.conf <<+END+38 nameserver $Name39 +END+40 41 service named start