Linux 安装配置DNS服务器

VM虚拟的环境CENTOS 6.5 IP:192.168.1.170

本地系统 IP:192.168.1.108

一:安装DNS

Linux安装DNS主要要安装2个程序:

[root@tiejiang ~]# yum install bind*   //linux下 用于解析DNS的程序
[root@tiejiang ~]# yum install caching-nameserver   //这是另外一个软件

安装完成后,会发现/VAR/NAMED/下多出了几个文件。证明安装好了。

二:配置DNS

[root@tiejiang ~]# vim  /etc/named.caching-nameserver.conf     //以下为完整配置后的配置文件内容
   // Provided by Red Hat caching-nameserver 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.  
   //  
   // DO NOT EDIT THIS FILE - use system-config-bind or an editor  
   // to create named.conf - edits to this file will be lost on   
   // caching-nameserver package upgrade.  
   //  
   options {  
       listen-on port 53 { any; };  
       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";  
  
       // Those options should be used carefully because they disable port  
       // randomization  
        query-source    port 53;     
       // query-source-v6 port 53;  
  
       allow-query     { any; };  
   #   allow-query-cache { any; };  
   };  
   logging {  
           channel default_debug {  
                   file "data/named.run";  
                   severity dynamic;  
           };  
   };  
   view localhost_resolver { //解析器  
       match-clients      { any; };//这里是允许那些地址用户使用本DNS进行解析  
       match-destinations { localhost; };  
       recursion yes;  
       include "/etc/named.rfc1912.zones";  
   };
[root@tiejiang ~]# vim  /etc/named.rfc1912.zones     //以下为完整配置后的配置文件内容:
   <pre name="code" class="java">// named.rfc1912.zones:  
   //  
   // Provided by Red Hat caching-nameserver package   
   //  
   // ISC BIND named zone configuration for zones recommended by  
   // RFC 1912 section 4.1 : localhost TLDs and address zones  
   //   
   // See /usr/share/doc/bind*/sample/ for example named configuration files.  
   //  
   zone "." IN {  
       type hint;  
       file "named.ca";  
   };  
     
   zone "localdomain" IN {  
       type master;  
       file "localdomain.zone";  
       allow-update { none; };  
   };  
  
   zone "localhost" IN {  
       type master;  
       file "localhost.zone";  
       allow-update { none; };  
   };  
  
   zone "0.0.127.in-addr.arpa" IN {  
       type master;  
       file "named.local";  
       allow-update { none; };  
   };  
  
   zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {  
           type master;  
       file "named.ip6.local";  
       allow-update { none; };  
   };  
     
   zone "255.in-addr.arpa" IN {  
       type master;  
       file "named.broadcast";  
       allow-update { none; };  
   };  
  
   zone "0.in-addr.arpa" IN {  
       type master;  
       file "named.zero";  
       allow-update { none; };  
   };  
  
   //正向解析  
   zone "cintv.cn" IN {  
       type master;  
       file "cintv.cn.zone";  //正向解析的具体解析文件  
       allow-update { none; };  
   };  
   //反向解析  
   zone "1.168.192.in-addr.arpa" IN {  
           type master;  
           file "cintv.cn.local"; //反向解析的具体解析文件  
           allow-update { none; };  
   };</pre><br>  
        <br>  
   <pre></pre>  
   <p></p>  
   <p>      <span style="font-size:16px"><strong>3。</strong></span>配置在(2)中所需要用到的 正向、反向 具体解析文件</p>  
   <blockquote>  
   <p><strong><span style="color:#3366FF">VI  /var/named/cintv.cn.zone</span></strong></p>  
   </blockquote>  
   <p>            新建<strong><span style="font-size:16px">正</span></strong>向具体解析文件: <strong>  
   <span style="color:#3366FF">VI  /var/named/cintv.cn.zone</span></strong>  <span style="color:#CC0000">  
   (在其他的网上资料说,所有的操作文件应该在路径  /var/named/chroot/  下的。本人也看过了那些路径中的文件,不过最后本人顺利完成的情况就只在本文记录的路径下。而且在那些路径下的以上提到的配置文件,都被我删除了。因为我怕会有冲突影响。没有做详细的实验研究,如果有读者清楚,望能告之。如若以后本人有时间实验,也会更新上来。)</span></p>  
   <p><span style="color:#CC0000">内容如下:</span></p>  
   <p><span style="color:#CC0000"></span></p>  
   <pre name="code" class="java">$TTL  86400            //具体正向解析文件  
   @       IN SOA  cintv.cn. root.cintv.cn (  
                       42      ; serial (d. adams)  
                       3H      ; refresh  
                       15M     ; retry  
                       1W      ; expiry  
                       1D )        ; minimum  
               IN NS       cintv.cn.  
   dns     IN A        192.168.1.170  
   www     IN A        192.168.1.170   //单独解析主机名为www的地址  
   *.cintv.cn. IN A        192.168.1.170   //泛域名解析</pre><br>  
   <br>  
               <strong><span style="color:#3366FF">VI  /var/named/cintv.cn.local</span></strong>  
   <p></p>  
   <p><span style="color:#CC0000">            <span style="color:#000000">新建<span style="font-size:16px"><strong>反</strong></span>向具体解析文件:</span><span style="color:#3366FF"><strong>VI  /var/named/cintv.cn.local</strong></span></span></p>  
   <p><span style="color:#CC0000">内容如下:</span></p>  
   <p><span style="color:#CC0000"></span></p>  
   <pre name="code" class="java">$TTL  86400  
   @       IN      SOA     cintv.cn. root.cintv.cn.  (  
                                         1997022700 ; Serial  
                                         28800      ; Refresh  
                                         14400      ; Retry  
                                         3600000    ; Expire  
                                         86400 )    ; Minimum  
             IN      NS      cintv.cn.  
   170       IN      PTR     www.cintv.cn.  //在该IP段内哪个地址(170)解析到此域名  
   170       IN      PTR     dns.cintv.cn.</pre><br>  
   <br>  
   <p></p>  
   <p><span style="color:#000000"></span></p>  
   <p></p>  
   <p><span style="color:#CC0000">         <strong>注意:无论正向还是反向的具体解析文件中,域名都是以英文符号“.”结尾的。</strong><br>  
   </span></p>  
   <p align="left"><br>  
   </p>  
   <p align="left">        <span style="font-size:16px"><strong>4。</strong></span>修改 <span style="color:#3333FF"></span><span style="color:#3366FF"><strong>vi  /etc/resolv.conf<span style="color:#000000">(配置本机适用什么DNS服务器的配置文件)</span><br>  
   </strong></span></p>  
   <blockquote>  
   <p align="left">内容如下:</p>  
   <p align="left"></p>  
   <pre name="code" class="java">; generated by /sbin/dhclient-script  
   search domain  
   nameserver 192.168.1.170  //改为了本机刚刚配置的DNS服务器地址了  
   nameserver 192.168.1.170  //linux可以配置多个DNS服务器的,多少个我就不知道了,默认是2个,我都改了.</pre>  
   <p></p>  
   <p align="left"></p>  
   <p></p>  
   <p align="left"><span style="font-size:16px"><strong>5。</strong></span>重启DNS服务器  <span style="color:#3366FF">  
   <strong>service named restart</strong></span></p>  
   <p align="left"><br>  
   </p>  
   <p align="left"><strong><span style="font-size:18px">三。<a href="http://lib.csdn.net/base/softwaretest" class="replace_word" title="软件测试知识库" target="_blank" style="color:#df3434; font-weight:bold;">测试</a></span></strong></p>  
   <p align="left">在命令行输入 ping www.cintv.cn 。成功的话就会解析到192.168.1.170.。</p>  
   <p align="left"><br>  
   </p>  
   <p align="left">后语:到此本人配置完成,在这里没少走弯路,都是因为网路上胡乱COPY的人弄的。在此整理出来希望对大家有用。<br>  
   </p>  
   <div align="left"><br>  
   </div>  
   <p><br>  
   </p>  
   </blockquote>  
   <pre></pre>  
   <pre></pre>

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/55200.html

(0)
上一篇 2021年8月7日
下一篇 2021年8月7日

相关推荐

发表回复

登录后才能评论