centos DNS服务器配置

yum install -y bind bind-chroot
sed -i 's#localhost#any#g' /etc/named.conf
sed -i 's#127.0.0.1#any#g' /etc/named.conf
sed -i 's#listen-on-v6#//listen-on-v6#g' /etc/named.conf

cat >/etc/named.conf<<EOF
options {
    listen-on port 53 { any; };
    //listen-on-v6 port 53 { ::1; };
    directory     "/var/named";
    dump-file     "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
    allow-query     { any; };
    recursion yes;
forward only ;
forwarders { 114.114.114.114; } ;
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "." IN {
    type hint;
    file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
EOF

\cp /etc/named.rfc1912.zones /etc/named.rfc1912.zones.bak
cat >>/etc/named.rfc1912.zones<<EOF
zone "test.com" IN {
    type master;
    file"test.com.zone";
    allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
    type master;
    file"192.168.1.zone";
    allow-update { none; };
};
EOF

cat >>/var/named/test.com.zone<<EOF
@   IN SOA  test.com.  root.test.com. (
              0   ; serial
              1D  ; refresh
              1H  ; retry
              1W  ; expire
              3H )  ; minimum
   IN  NS  dns.test.com.
dns   IN  A   192.168.1.7
test   IN  A   192.168.1.7
www   IN  A   192.168.1.8
EOF
cat >>/var/named/192.168.1.zone<<EOF
@   IN SOA  test.com.  root.test.com. (
              0   ; serial
              1D  ; refresh
              1H  ; retry
              1W  ; expire
              3H )  ; minimum
   IN  NS  dns.test.com.
7  IN  PTR   dns.test.com.
7   IN  PTR   test.test.com.
8   IN  PTR   www.test.com.
EOF
service named start
01-26 16:26