Centos6.5 DNS配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos6.5 DNS配置相关的知识,希望对你有一定的参考价值。

服务器端:192.168.186.130

1、安装

# yum -y install bind*

2、主要配置文件

 1 [root@localhost named]# vim /etc/named.conf  
 2 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS  
 3 // server as a caching only nameserver (as a localhost DNS resolver only).  
 4 //  
 5 // See /usr/share/doc/bind*/sample/ for example named configuration files.  
 6 //  
 7   
 8 options {  
 9         listen-on port 53 { any; };//开启监听端口53并接受任意IP连接  
10         #listen-on-v6 port 53 { ::1; };  
11         directory       "/var/named"; //正向反向区域文件存放目录  
12         dump-file       "/var/named/data/cache_dump.db";  
13         statistics-file "/var/named/data/named_stats.txt";  
14         memstatistics-file "/var/named/data/named_mem_stats.txt";  
15         allow-query     { 0.0.0.0/0; }; //允许任意IP查询  
16         recursion yes;  
17   
18         dnssec-enable yes;  
19         dnssec-validation yes;  
20         dnssec-lookaside auto;  
21   
22         /* Path to ISC DLV key */  
23         bindkeys-file "/etc/named.iscdlv.key";  
24   
25         managed-keys-directory "/var/named/dynamic";  
26 };  
27   
28 logging {  
29         channel default_debug {  
30                 file "data/named.run";  
31                 severity dynamic;  
32         };  
33 };  
34   
35 zone "." IN {  
36         type hint;  
37         file "named.ca";  
38 };  
39   
40 include "/etc/named.rfc1912.zones";  
41 include "/etc/named.root.key";  

3、创建正反向区域

 1 [root@localhost named]# vim /etc/named.rfc1912.zones  
 2 // named.rfc1912.zones:  
 3 //  
 4 // Provided by Red Hat caching-nameserver package  
 5 //  
 6 // ISC BIND named zone configuration for zones recommended by  
 7 // RFC 1912 section 4.1 : localhost TLDs and address zones  
 8 // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt  
 9 // (c)2007 R W Franks  
10 //  
11 // See /usr/share/doc/bind*/sample/ for example named configuration files.  
12 //  
13   
14 zone "gxdemo.com" IN {  
15         type master;  
16         file "named.gxdemo.com";  
17         allow-update { none; };  
18 };  
19   
20 zone "186.168.192.in-addr.arpa" IN {  
21         type master;  
22         file "192.168.186.arpa";  
23         allow-update { none; };  
24 };  

4、配置正向文件

 1 [root@localhost named]# vim /var/named/named.gxdemo.com  
 2 $TTL 1D  
 3 @       IN SOA  gxdemo.com. rname.invalid. (  
 4                                         0       ; serial  
 5                                         1D      ; refresh  
 6                                         1H      ; retry  
 7                                         1W      ; expire  
 8                                         3H )    ; minimum  
 9         NS      @  
10         A       127.0.0.1  
11         AAAA    ::1  
12 gx IN A 192.168.186.36  

5、配置反向文件

 1 [root@localhost named]# vim /var/named/192.168.186.arpa  
 2 $TTL 1D  
 3 @       IN SOA  gxdemo.com. rname.invalid. (  
 4                                         0       ; serial  
 5                                         1D      ; refresh  
 6                                         1H      ; retry  
 7                                         1W      ; expire  
 8                                         3H )    ; minimum  
 9         NS      @  
10         AAAA    ::1  
11 36      PTR     gx.  

6、修改文件所属组

1 [root@localhost named]chown root:named 192.168.186.arpa
2 [root@localhost named]chown root:named named.gxdemo.com

7、修改DNS文件

1 [root@localhost named]# vim /etc/resolv.conf  
2 nameserver 192.168.186.130  

8、测试

查看是哪个DNS服务器

 1 [root@localhost named]# dig -t ns gx.gxdemo.com
 2 
 3 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6_9.4 <<>> -t ns gx.gxdemo.com
 4 ;; global options: +cmd
 5 ;; Got answer:
 6 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17658
 7 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
 8 
 9 ;; QUESTION SECTION:
10 ;gx.gxdemo.com.            IN    NS
11 
12 ;; AUTHORITY SECTION:
13 gxdemo.com.        10800    IN    SOA    gxdemo.com. rname.invalid. 0 86400 3600 604800 10800
14 
15 ;; Query time: 0 msec
16 ;; SERVER: 127.0.0.1#53(127.0.0.1)
17 ;; WHEN: Sun Jul 23 04:38:34 2017
18 ;; MSG SIZE  rcvd: 80

以上是关于Centos6.5 DNS配置的主要内容,如果未能解决你的问题,请参考以下文章

Centos6.5下配置DNS服务器

Centos6.5配置DNS的主从服务器

CentOS6.5设置静态IP、网关、配置DNS,解决ping不通外网问题

CentOS6.5安装之DNS配置错误,yum install 软件报错:ERROR 6或者56错误提示”could not retrieve mirrorlist http://mirrorli(代

Centos6.5-dnsmasq安装

CentOS6.5安装配置sendmail+dovecot