centos7安装dns服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7安装dns服务器相关的知识,希望对你有一定的参考价值。

  1. 安装软件:
    yum  -y  install  bind  bind-utils
  2. 修改配置文件:
    a. 修改主配置文件:vim /etc/named.conf
    options {
    listen-on port 53 { 127.0.0.1;192.168.8.81; };
    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     { lee; };
    forwarders { 8.8.8.8;114.114.114.114; };
    recursion yes;
    dnssec-enable yes;
    dnssec-validation yes;
    bindkeys-file "/etc/named.iscdlv.key";
    managed-keys-directory "/var/named/dynamic";
    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
    };
    acl lee {
    192.168.8.0/24;
    };
    logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
    };
    zone "." IN {
    type hint;
    file "named.ca";
    };
    zone "lee.com" {
    type master;
    file "/etc/named/zones/lee.com.zone";
    };
    zone "168.192.in-addr.arpa" {
    type master;
    file "/etc/named/zones/192.168.zone";
    };
    include "/etc/named.rfc1912.zones";
    include "/etc/named.root.key";

    b. 创建正向解析域:vim /etc/named/zones/lee.com.zone

    $TTL 1D
    @       IN      SOA     ns1.lee.com. admin.lee.com. (
    3         ; Serial
    604800     ; Refresh
    86400     ; Retry
    2419200     ; Expire
    604800 
    )
    IN NS ns1.lee.com.
    ns1.lee.com. IN A 192.168.8.81
    www.lee.com. IN A 192.168.8.81
    blog.lee.com. IN A 192.168.8.82
    shop.lee.com. IN A 192.168.8.83

    c. 创建反向解析域:vim /etc/named/zones/192.168.zone

    
    $TTL 1D
    @       IN      SOA     ns1.lee.com. admin.lee.com. (
    3         ; Serial
    604800     ; Refresh
    86400     ; Retry
    2419200     ; Expire
    604800 

)
IN NS ns1.lee.com.
81.8 IN PTR ns1.lee.com.
81.8 IN PTR www.lee.com.
82.8 IN PTR blog.lee.com.
83.8 IN PTR shop.lee.com.

3. 检查配置文件语法:
a. 检查主配置文件语法:

named-checkconf

b. 检查正向解析域的语法:

named-checkzone lee.com /etc/named/zones/lee.com.zone

![](http://i2.51cto.com/images/blog/201802/08/33fcaefd088280a141ef16ecb7fe1128.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
c. 检查反向解析域的语法:

named-checkzone 192.168.in-addr.arpa /etc/named/zones/192.168.zone

![](http://i2.51cto.com/images/blog/201802/08/870cf5408eb4dde17dde61cca05c0bcd.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
4. 启动服务:

systemctl start named

5. 客户端验证:
a. linux客户端:
a-1. 修改DNS服务器:vim  /etc/resolv.conf

nameserver 192.168.8.81


![](http://i2.51cto.com/images/blog/201802/08/56d0fb88b12988af58e763d3141f621b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
a-2. 验证:
![](http://i2.51cto.com/images/blog/201802/08/8b4134acdf2357b7051bac7fec01bd87.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
b. windows客户端:
b-1. 修改DNS服务器:
![](http://i2.51cto.com/images/blog/201802/08/ab9c815ac66d0688a3d0ca3effdabd77.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/f4b3b3bc5863e5087be0a7cf4c5991dd.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/4fa411cc0b4b85a60c30a4fe698feecd.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/b538ed75cd03e2f70941db95d5c40056.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/61187013b98c8ce8efb44c6e7b93e2fa.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/ad3af6840a2c5b29698b895722f1f5d6.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
b-2. 验证:
![](http://i2.51cto.com/images/blog/201802/08/f9900d18f871dcc9452c0ea555f34397.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](http://i2.51cto.com/images/blog/201802/08/115d523539e062301dc29067fa695c19.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

以上是关于centos7安装dns服务器的主要内容,如果未能解决你的问题,请参考以下文章

centos7为啥安装不了bind

CentOS7.4下DNS服务器软件BIND安装及相关的配置

centos7安装dns服务器

Linux CentOS7 DNS服务器配置

Centos7下dnscrypt-proxy安装

centos7配置dnsmasq