linux下bind9安装配置一例

2019-10-15 10:26:30王振洲

一,安装BIND
  1.下载BIND   http://www.isc.org  也可以去本站下载 bind9 dns软件。
  2.编译安装


#  tar zxvf bind-9.4.0.tar.gz
   #  cd bind-9.4.0
   # ./configure sysconfdir=/etc  //更多安装选项 ./configure --help
   #  make
   # make install

二,配置BIND
A.创建需要文件
1)./etc/named.conf  
   # vi /etc/named.conf 推出保存即可 或 touch /etc/named.conf

2)./etc/rndc.conf  
   # rndc-confgen > /etc/rndc.conf

B.创建目录 /var/named
   # mkdir /var/named

B.编辑/etc/named.conf  内容如下


options {
       directory "/var/named";   //表示默认的数据库文件在/var/named中 若没有需手动创建
      // pid-file  "/var/run/named/named.pid"; //运行的PID文件路径,用于使用其他用户启动named
          };
        zone "." {            //创建root域

         type hint;
         file "named.ca";
         };
        zone "localhost" {   //创建 localhost域
         type master;
         file "named.local";
        };
       zone "example.com" {  //创建 example.com域
         type master;
         file "example.com.zone";
       };
      zone "0.0.127.in-addr.arpa"{ //localhost的反解析
          type master;
         file "127.0.0.zone";
      };
     zone "100.168.192.in-addr.arpa" {  //example.com的反向解析
          type master;
          file "192.168.100.zone";
      };
//这段文件在/etc/rndc.conf 的尾部需拷贝才能使用 # tail +13 /etc/rndc.conf >>/etc/named.conf
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
        algorithm hmac-md5;
        secret "HWM3L+e7LWDZJJ/dJEzQEw==";
 };

 controls {
        inet 127.0.0.1 port 953