CentOS7上搭建DNS服务器

参考网站:

  1. 如何在CentOS7上搭建DNS服务器
  2. 如何在Ubuntu上搭建DNS服务器
  3. 详细文档参考

搭建DNS服务的步骤比较简单,如果出现问题,最重要的就是查看日志,定位问题,祝你好运!

开启、关闭和查看DNS服务器日志如下:

# 初次为开启
rndc querylog 
tail -f /var/log/message
# 再次为关闭(建议关闭,不然日志太多)
rndc querylog

DNS服务器日志开启参考

简要流程日下:

1. 安装bind

sudo yum install bind bind-utils

2. 配置正向和方向DNS解析

vi /etc/named.conf

修改或添加如下行:

listen-on port 53 { any; };
allow-query     { any; };
allow-transfer {172.16.0.12;};  
forwarders { 114.114.114.114; 8.8.8.8; };

allow-transfer用于执向另外一台DNS服务器, 只有一台的情况下,可以不写。

添加正向解析配置:

zone "nyc3.example.com" {
    type master;
    file "/etc/named/zones/db.nyc3.example.com"; # zone file path
};

文件名可以任意位置,不过需要注意权限,要求为named组。
chrow root:named

添加方向解析配置

zone "128.10.in-addr.arpa" {
    type master;
    file "/etc/named/zones/db.10.128";  # 10.128.0.0/16 subnet
};

注意这里的IP是反者写的:10.128.0.0/16, 需要写成:128.10.in-addr.arpa

配置文件如下:

$TTL    604800
@       IN      SOA     ns1.nyc3.example.com. admin.nyc3.example.com. (
                  3       ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
; name servers - NS records
     IN      NS      ns1.nyc3.example.com.
     IN      NS      ns2.nyc3.example.com.

; name servers - A records
ns1.nyc3.example.com.          IN      A       10.128.10.11
ns2.nyc3.example.com.          IN      A       10.128.20.12

; 10.128.0.0/16 - A records
host1.nyc3.example.com.        IN      A      10.128.100.101
host2.nyc3.example.com.        IN      A      10.128.200.102
$TTL    604800
@       IN      SOA     nyc3.example.com. admin.nyc3.example.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; name servers
      IN      NS      ns1.nyc3.example.com.
      IN      NS      ns2.nyc3.example.com.

; PTR Records
11.10   IN      PTR     ns1.nyc3.example.com.    ; 10.128.10.11
12.20   IN      PTR     ns2.nyc3.example.com.    ; 10.128.20.12
101.100 IN      PTR     host1.nyc3.example.com.  ; 10.128.100.101
102.200 IN      PTR     host2.nyc3.example.com.  ; 10.128.200.102

3. 启动服务

systemctl start named.service
systemctl enable named.service
systemctl reload named.service

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值