linux下搭建DNS子域及相关授权详解
forward功能是本地无法解析的域名,转发给指定DNS服务器
forward only; 所有无法解析的域名,都转发给指定DNS服务器,必须有解析结果
forward first;无法解析的域名,转发给指定DNS服务器,如果指定DNS服务器也无法解析,
再通过自己的DNS服务器向根进行转发解析
forwarders { 指定DNS服务器; }; 如本地DNS无法解析,向指定DNS服务器转发解析域名
注意forward与forwarders同时使用
2.搭建主域与子域,要求如下:
A.主域为willow.com,IP为1.1.1.18
B.子域为a.willow.com,IP为1.1.1.20
C.如果子域无法解析willow.com主域名,请将转发器指向主域willow.com,其他域名自己解析
D.如果子域无法的解析所有非本地域名,请将转发器指向主域willow.com
2.1.新增主域willow.com配置文件,方法没有变化与之前博客搭建DNS一样
vim /etc/named.conf,新增如下内容:
options {
directory "/var/named";
allow-recursion { 1.1.1.0/24; };
notify yes;
also-notify { 1.1.1.19; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};
zone "willow.com" {
type master;
file "willow.com.zone";
allow-transfer { 1.1.1.19; };
};
zone "1.1.1.in-addr.arpa" IN {
type master;
file "1.1.1.zone";
allow-transfer { 1.1.1.19; };
};
2.2.新增willow.com.zone正向区域文件
vim /var/named/willow.com.zone 主要将子域a.wilow.com的NS和A记录增加至配置文件中
$TTL 600
willow.com. IN SOA ns1.willow.com. root.willow.com. (
20160521
1H
10M
3D
1D )
willow.com. IN NS ns1
willow.com. IN NS ns2
IN MX 10 mail
a IN NS ns1.a
ns1.a IN A 1.1.1.20
ns1 IN A 1.1.1.18
ns2 IN A 1.1.1.19
mail.willow.com. IN A 1.1.1.23
www IN A 1.1.1.30
www IN A 1.1.1.31
www IN A 1.1.1.32
ftp IN CNAME www.willow.com.
hello IN A 1.1.1.33
2.3.新增子域a.willow.com的named.conf文件
如果子域无法的解析所有非本地域名,请将转发器指向主域willow.com
vim /etc/named.conf 新增如下内容:
options {
directory "/var/named";
forward first; #开启转发功能
forwarders { 1.1.1.18; }; #转发器指定主域
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};
zone "a.willow.com" {
type master;
file "a.willow.com.zone";
};
2.4.新增子域a.willow.com的正向区域文件
vim /var/named/a.willow.com,新增如下内容:
$TTL 600
a.willow.com. IN SOA ns1.a.willow.com. root.a.willow.com. (
20160516
1H
10M
3D
1D )
a.willow.com. IN NS ns1
IN MX 10 mail
ns1 IN A 1.1.1.20
mail IN A 1.1.1.223
www IN A 1.1.1.224
以上子域授权等DNS服务器建立完成,可测试使用并正常
2.5.如果子域无法解析willow.com主域名,请将转发器指向主域willow.com,其他域名自己解析
仅修改子域主配置文件named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};
zone "a.willow.com" {
type master;
file "a.willow.com.zone";
};
zone "willow.com" {
type forward;
forward first;
forwarders { 1.1.1.18; };
};
请注意,forward和forwarders放置位置不同,达到的效果不一样,一个放在options中,另一外放在zone命令单元中,请看仔细了,哈!
本文出自 “夏维柳” 博客,请务必保留此出处http://willow.blog.51cto.com/6574604/1774364
原文地址:http://willow.blog.51cto.com/6574604/1774364