欢迎访问IT教程网

DNS服务器安装使用

Linux admin 152℃ 0评论

安装bind

yum install bind

配置文件的格式/etc/named.conf

options{
     //全局选项
}
zone zone name {
   //定于区域
}
logging{
    //日志文件
}
include:加载别的文件

主配置文件范例

options {
    listen-on port 53 { 192.168.57.3; };
    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     { any; };
        forwarders      {192.168.57.1; } ;
    recursion yes;
        dnssec-enable no;
        dnssec-validation no;
    /* Path to ISC DLV key */
    bindkeys-file /etc/named.iscdlv.key;
    managed-keys-directory /var/named/dynamic;
    pid-file /run/named/named.pid;
    session-keyfile /run/named/session.key;
};
logging {
        channel default_debug {
                file data/named.run;
                severity dynamic;
        };
};
zone . IN {
    type hint;
    file named.ca;
};
include /etc/named.rfc1912.zones;
include /etc/named.root.key;

检查配置文件是否错误

named-checkconf

启动服务

systemctl start named

添加一个名为test.com的正向主机域

在/etc/named.rfc1912.zones文件末尾

zone test.com IN {
      type   master;
      file    test.com.zone;
     allow-update {192.168.57.4;192.168.57.5;  };
};

创建正向解析zone文件 ,

cat /var/named/test.com.zone 
$TTL 600    ; 10 minutes
@               IN SOA  ns.test.com. dnsadmin.test.com. (
                2020072801 ; serial
                10800      ; refresh (3 hours)
                900        ; retry (15 minutes)
                604800     ; expire (1 week)
                86400      ; minimum (1 day)
                )
            NS   ns.test.com.
$ORIGIN test.com.
$TTL 60 ; 1 minute
ns                  A    192.169.57.3
www                     A    192.168.57.4

添加反向解析域

/etc/named.rfc1912.zones

zone 57.168.192.in-addr.arpa IN {
        type master;
        file 57.168.192.in-addr.arpa.zone;
        allow-update { 192.168.57.4;192.168.57.5;  };
};

添加反向解析zone文件

 cat /var/named/57.168.192.in-addr.arpa.zone 
$TTL 600    ; 10 minutes
@               IN SOA  ns.test.com. dnsadmin.test.com. (
                2020072801 ; serial
                10800      ; refresh (3 hours)
                900       ; retry (15 minutes)
                604800     ; expire (1 week)
                86400      ; minimum (1 day)
                )
                NS   ns.test.com.
$ORIGIN 57.168.192.in-addr.arpa.
$TTL 60 ; 1 minute
3           PTR      ns.test.com.
4           PTR      www.test.com.

查看DNS解析

[root@localhost ~]# dig -t A www.test.com @192.168.57.3 +short
192.168.57.4
[root@localhost ~]# dig -t A ns.test.com @192.168.57.3 +short
192.168.57.3

创建DNS从服务器

从服务器/etc/named.conf加入如下内容

masterfile-format text;

主服务器/etc/named.conf加入如下内容

allow-transfer { 192.168.57.4; };
also-notify { 192.168.57.4; };

在从服务器上添加需要同步的zone,/etc/named.rfc1912.zones

zone test.com IN {
  type  slave;
  masters { 192.168.57.3; };
  file  slaves/test.com.zone;
};

启动从服务器并查看是否同步/var/named/slaves/test.com.zone

本文固定链接:IT教程网 » DNS服务器安装使用
本站内容除特别标注外均为原创,欢迎转载,但请保留出处!

喜欢 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址