DNS服务器配置

dnsf服务器配置

官网文档: https://help.ubuntu.com/lts/serverguide/dns.html
安装
在终端提示符后输入以下命令来安装 dns:

sudo apt install bind9

sudo apt install dnsutils
概览
cd /etc/bind
vim named.conf

# 默认的安装后就生效解析
vim named.conf.default-zones
  zone "." 默认解析
      /db.root
  zone "localhost" 主机解析正向
    db.local

  zone "127..." 反向解析 ip转换为域名

#dns服务器配置
vim named.conf.options

# 哪些域名在本地解析
vim /etc/bind/named.local
配置
vim /etc/bind/named.conf.local

  zone "example.com" {
      type master;
      file "/etc/bind/db.example.com";

};
sudo cp /etc/bind/db.local /etc/bind/db.example.com

vim /etc/bind/db.example.com
  ;
  ; BIND data file for example.com
  ;
  $TTL    604800
  @       IN      SOA     example.com. root.example.com. (
                                2         ; Serial
                            604800        ; Refresh
                            86400         ; Retry
                            2419200       ; Expire
                            604800 )      ; Negative Cache TTL
        IN      A       192.168.1.10
  ;
  @       IN      NS      example.com.
  @       IN      A       192.168.1.10
  @       IN      AAAA    ::1
  ns      IN      A       192.168.1.10
重启服务
sudo systemctl restart bind9.service
设置dns服务器

vim /etc/resolv.conf
nameserver

** 此配置文件重启服务器会清空,不清空配置:
sudo vim /etc/resolvconf/resolv.conf.d/base

添加DNS服务器地址
nameserver 

刷新配置文件
sudo resolvconf -u
测试

ping ns.example.com
host ns.example.com

你可能感兴趣的:(DNS服务器配置)