当前位置:   article > 正文

ubuntu16+bind9 搭建dns服务器_ubuntu bind9

ubuntu bind9

需求:使用bind9搭建一台dns服务器,为其他服务器之间的访问提供dns解析服务

dns服务器:192.168.xx.32
web服务器:192.168.xx.31
db服务器:192.168.xx.33

1:安装bind9

apt install bind9
  • 1

2:编辑bind配置文件(/etc/bind/named.conf.local)指定域的区块文件

vim /etc/bind/named.conf.local
  • 1

添加下列内容

zone "tor.com"{                          # “tor.com”可以理解为监听区域,根据自己的域名设置
    type master;
    file "/etc/bind/zones/db.tor.com";   # 区文件路径(稍后在相应位置创建区文件就好,路径不必严格照搬)

};                                       # zone可以定义多个
  • 1
  • 2
  • 3
  • 4
  • 5

3:进入/etc/bind/目录下,没有zones文件夹就创建。

4:在/etc/bind/zones/路径下创建区文件

cp /etc/bind/db.empty /etc/bind/zones/db.tor.com
  • 1

我这里创建的是db.tor.com,和前面定义的路径匹配就行

5:编辑区文件 db.tor.com

; BIND reverse data file for empty rfc1918 zone
;
; DO NOT EDIT THIS FILE - it is used for multiple zones.
; Instead, copy it, edit named.conf, and use that copy.
;
$TTL    86400
@       IN      SOA     ns1.tor.com. admin.tor.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
;
@       IN      NS      localhost.               #域名服务器
;tor.com IN      NS      192.168.xx.32    
;@       IN      A       127.0.0.1                #ipv4地址
;@       IN      AAAA    ::1                       #ipv6地址

web     IN      A       192.168.xx.31			#提供web服务的服务器
db      IN      A       192.168.xx.33             #提供数据库服务的服务器
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

SerialNumber :每次编辑区文件后数字请自行+1,用于从服务器判断何时获取最新的区数据
@:表示当前域
NS:域名服务器
“;”:注释

6:编辑 named.conf.options 文件

vim named.conf.options
  • 1

设置监听端口(在options内加入)

listen-on port 53 {127.0.0.1;192.168.xx.32; }; # 此处填写ns1的内网IP地址。仅在内网监听

7:重启bind服务

service bind9 restart 
  • 1

8:配置服务器dns指向dns服务器

例如在角色为web的服务器上编辑 /etc/resolv.conf 文件,加入如下内容

nameserver 192.168.xx.32 #dns服务器地址
search DHCP HOST

保存退出,接下来在web服务器上ping db.tor.com就可以自动解析到角色为db的服务器地址
也可以使用 nslookup db.tor.com 验证

区文件配置说明参考

bind9配置说明

dns解析过程全解

常用域名记录解释

本文参考

ubuntu下配置bind9为局域网的DNS服务器

ubuntu16.04下搭建bind9记录

PS:自由域

zone
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/579847
推荐阅读
相关标签
  

闽ICP备14008679号