options {
listen-on port 53 { any; };
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 { any; };
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* 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";
修改/etc/named.rfc1912.zones添加DNS正反向解析规则
// 正向解析
zone "ns2250225.com" IN {
type master;
file "ns2250225.com.zone";
allow-update { none; };
};
// 反向解析
zone "14.168.192.in-addr.arpa" IN {
type master;
file "192.168.14.zone";
allow-update { none; };
};
创建对应的配置文件
创建/var/named/ns2250225.com.zone
$TTL 3600
@ IN SOA ns.ns2250225.com. admin.ns2250225.com. (4 3600 3600 7200 7200)
IN NS ns
ns IN A 192.168.14.250
www IN A 192.168.14.251
mail IN A 192.168.14.252
创建/var/named/192.168.14.zone
$TTL 3600
@ IN SOA ns.ns2250225.com. admin.ns2250225.com. (4 3600 3600 7200 7200)
IN NS ns.ns2250225.com.
250 IN PTR ns.ns2250225.com.
251 IN PTR www.ns2250225.com.
252 IN PTR mail.ns2250225.com.
这两类记录都负责将一台主机映射至一个IP地址
其中的“A”记录用于将一台主机映射至一个IPv4 IP地址
而“AAAA”记录则用于将主机映射至IPv6 IP地址
如:
ns1.domain.com. IN A 111.222.111.222
CNAME记录
CNAME记录负责为我们的服务器的规范名称定义一条别名
举例来说,我们可以使用一条A命名记录定义“server1”主机,而后将“www”作为该主机的别名:
server1 IN A 111.111.111.111
www IN CNAME server1
MX记录
MX记录用于定义该域名所使用的邮件交换方式,其能够帮助我们的邮件信息能够正确抵达邮件服务器
MX记录一般指向由A或者AAAA记录定义的主机,而非由CNAME定义的主机
因此,假设我们有两台邮件服务器。其记录内容应如下所示:
IN MX 10 mail1.domain.com.
IN MX 50 mail2.domain.com.
mail1 IN A 111.111.111.111
mail2 IN A 222.222.222.222
在本示例中,“mail1”主机为首选邮件交换服务器
NS记录
此记录类型用于定义该区域所使用的命名服务器
与MX记录类似,NS记录包含三条全区域参数,因此其同样不需要填写主机。一般来讲,其内容应如下所示:
IN NS ns1.domain.com.
IN NS ns2.domain.com.
PTR记录
PTR记录用于将一个名称关联至一个IP地址, PTR记录属于A或者AAA记录的倒数
下面来看111.222.333.444的PTR记录示例:
444.333.222.111.in-addr.arpa. 33692 IN PTR host.example.com.