DNS服务的配置

Edit on Github

概要

  • 软件:bind
  • 环境:Archlinux
  • 要求:正反向解析localhost、127.0.0.1、maxint.org(内部网络)、192.168.0.
  • 注意事项:#chown named.named /var/named/maxint.org.zone等,不然域名解析不成功
  • 测试:
#digmaxint.org#host-t A(NS)www(mail\news).maxint.org

/etc/named.conf

// /etc/named.conf
//
options {
         directory"/var/named";
         pid-file"/var/run/named/named.pid";
         auth-nxdomain yes;
         datasize default;
         allow-recursion { 127.0.0.1; };
};
zone"localhost"IN {
         type master;
         file"localhost.zone";
         allow-update { none; };
         allow-transfer { any; };
};
zone"0.0.127.in-addr.arpa"IN {
         type master;
         file"127.0.0.zone";
         allow-update { none; };
         allow-transfer { any; };
};
zone"."IN {
         type hint;
         file"root.hint";
};
zone"maxint.org"IN {
         type master;
         file"maxint.org.zone";
         allow-update { none; };
         allow-transfer { any; };
};
zone"0.168.192.in-addr.arpa"IN {
         type master;
         file"192.168.0.zone";
};
logging {
         channel xfer-log {
                 file"/var/log/named.log";
                 print-category yes;
                 print-severity yes;
                 print-time yes;
                 severity info;
         };
         category xfer-in { xfer-log; };
         category xfer-out { xfer-log; };
         category notify { xfer-log; };
};

/var/named/maxint.org.zone

$TTL     1D
$ORIGIN maxint.org.
@                        1D IN SOA        @ root (
                                          42               ; serial (yyyymmdd##)
                                          3H               ; refresh
                                          15M              ; retry
                                          1W               ; expiry
                                          1D )             ; minimum ttl
                         1D IN NS         @
                         1D IN MX 10      mail
                         1D IN A          192.168.0.98
www                      1D IN A          192.168.0.98
mail                     1D IN A          192.168.0.3
news                     1D CNAME         www

/var/named/192.168.0.zone

$TTL     1D
$ORIGIN 0.168.192.in-addr.arpa.
@                        1D IN SOA        @ root.maxint.org. (
                                          42               ; serial (yyyymmdd##)
                                          3H               ; refresh
                                          15M              ; retry
                                          1W               ; expiry
                                          1D )             ; minimum ttl
                         1D IN NS         maxint.org.
98                       1D IN PTR        maxint.org.
3                        1D IN PTR        mail.maxint.org.

配置根服务器的NS记录

#dig -t NS .>/var/named/root.hint