bind的安装实现

首先介绍一下我的测试环境:centos 7+入网(为了试行一下自己的安装文档,才装的虚拟机)

1> yum install bind bind-chroot -y

    因为刚刚安装的虚拟机,这里我就不检查了;

2>vim named.conf

[root@localhost named]# cat /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
 listen-on port 53 { any;127.0.0.1; };
// 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     { localhost; };

 recursion yes;

 dnssec-enable no;
 dnssec-validation no;

 /* Path to ISC DLV key */
 bindkeys-file "/etc/named.iscdlv.key";

 managed-keys-directory "/var/named/dynamic";

 pid-file "/run/named/named.pid";
 session-keyfile "/run/named/session.key";
};

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";

3>systemctl start named.service

    启动服务;centos 6: service named start

4>ss -tunlp|grep 53

    有看到 "*:53" ,这说就已经开始启用了

5>vim /etc/named.rfc1912.zones

    //在最后一行加入

    zone "mologa.com" IN {
    type master;
    file "mologa.com.zone";
    };

6>rndc reload

7>rndc status

8>tail /var/log/messages

    以上重载,看状态,看报错日志

9>vi /var/named/mologa.com.zone

    $TTL 1D
    $ORIGIN mologa.com.
    @ IN SOA ns1.mologa.com.  admin.mologa.com. (
                                   2016031601
                                   1H
                                   5M
                                   3D
                                   1D )
       IN NS ns1
       IN NS ns2
ns1 IN A 192.168.150.152
ns2 IN A 192.168.150.150
*     IN A 192.168.150.152

10>named-checkconf; named-checkzone "mologa.com" /var/named/mologa.com.zone
     zone mologa.com/IN: loaded serial 2016031601
     OK

     能得到以上两行,说明zone空间检测ok了;

11>cd /var/named/

12>chown :named mologa.com.zone

13>chmod 640 mologa.com.zone

14>rndc reload

      显示ok就通过了,然后再操作一下<8>步;

15>dig -t A www.mologa.com @192.168.150.152

      

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.2 <<>> -t A www.mologa.com @192.168.150.152
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19286
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.mologa.com.   IN A

;; ANSWER SECTION:
www.mologa.com.  86400 IN A 192.168.150.152

;; AUTHORITY SECTION:
mologa.com.  86400 IN NS ns2.mologa.com.
mologa.com.  86400 IN NS ns1.mologa.com.

;; ADDITIONAL SECTION:
ns1.mologa.com.  86400 IN A 192.168.150.152
ns2.mologa.com.  86400 IN A 192.168.150.150

;; Query time: 0 msec
;; SERVER: 192.168.150.152#53(192.168.150.152)
;; WHEN: Wed Mar 16 01:57:41 PDT 2016
;; MSG SIZE  rcvd: 127

    

    上述ou啦!(根据自己的需求改)

 

原创文章,作者:mologa,如若转载,请注明出处:http://www.178linux.com/12881

评论列表(1条)

  • stanley
    stanley 2016-03-20 11:50

    多写blog, 没有格式化显得特别乱