centos6.8搭建DNS服务器(bind)

一、安装软件

[root@dns-server named]# yum install bind -y
[root@dns-server named]# /etc/init.d/named start
Starting named:                                            [  OK  ]
[root@dns-server named]# 

二、配置name参数

[root@dns-server 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 { 192.168.17.149; };  #修改为本机的ip地址
    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; };       #修改为any
    recursion yes;

    dnssec-enable yes;
    dnssec-validation yes;

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

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

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
    type hint;
    file "named.ca";
};
#添加正向区域
zone "test.com" IN {
    type master;
    file "test.com.zone";
};
#添加反向区域
zone "1.168.192.in-addr.arpa." IN {
    type master;
    file "1.168.192.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

三、配置正反向文件

[root@dns-server named]# cd /var/named/
[root@dns-server named]# pwd
/var/named

正向文件

[root@dns-server named]# cat test.com.zone 
$TTL 1D
@   IN SOA  dns.test.com.  root.test.com.(
                20160529
                1H
                15M
                1W
                1D)
@  IN NS    dns.test.com.
dns                IN  A     192.168.1.2
cw                 IN  A     192.168.1.11
xs                 IN  A     192.168.1.12
jl                 IN  A     192.168.1.13
oa                 IN  A     192.168.1.13
[root@dns-server named]# 

反向文件

[root@dns-server named]# cat 1.168.192.zone 
$TTL 86400
@     IN   SOA   1.168.192.in-addr.arpa.    root.test.com.(
                 20160529
                 1H
                 15M
                 1W
                 1D)
@          IN    NS    dns.test.com.
2      IN   PTR   dns.test.com.
11     IN   PTR   cw.test.com.
12     IN   PTR   xs.test.com.
13     IN   PTR   jl.test.com.
13     IN   PTR   oa.test.com.

四、测试DNS解析

[root@dns-server named]# nslookup 
> dns.test.com
Server:     192.168.17.149
Address:    192.168.17.149#53

Name:   dns.test.com
Address: 192.168.1.2
> cw.test.com
Server:     192.168.17.149
Address:    192.168.17.149#53

Name:   cw.test.com
Address: 192.168.1.11
> 192.168.1.13
Server:     192.168.17.149
Address:    192.168.17.149#53

13.1.168.192.in-addr.arpa   name = jl.test.com.
13.1.168.192.in-addr.arpa   name = oa.test.com.
> 192.168.1.12
Server:     192.168.17.149
Address:    192.168.17.149#53

12.1.168.192.in-addr.arpa   name = xs.test.com.

你可能感兴趣的:(Linux技术)