forward功能是本地无法解析的域名,转发给指定DNS服务器 forward only; 所有无法解析的域名,都转发给指定DNS服务器,必须有解析结果 forward first;无法解析的域名,转发给指定DNS服务器,如果指定DNS服务器也无法解析, 再通过自己的DNS服务器向根进行转发解析 forwarders { 指定DNS服务器; }; 如本地DNS无法解析,向指定DNS服务器转发解析域名 注意forward与forwarders同时使用 2.搭建主域与子域,要求如下: A.主域为itnetcn.com,IP为1.1.1.18 B.子域为a.itnetcn.com,IP为1.1.1.20 C.如果子域无法解析itnetcn.com主域名,请将转发器指向主域itnetcn.com,其他域名自己解析 D.如果子域无法的解析所有非本地域名,请将转发器指向主域itnetcn.com 2.1.新增主域itnetcn.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 "itnetcn.com" { type master; file "itnetcn.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.新增itnetcn.com.zone正向区域文件 vim /var/named/itnetcn.com.zone 主要将子域a.wilow.com的NS和A记录增加至配置文件中 $TTL 600 itnetcn.com. IN SOA ns1.itnetcn.com. root.itnetcn.com. ( 20160521 1H 10M 3D 1D ) itnetcn.com. IN NS ns1 itnetcn.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.itnetcn.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.itnetcn.com. hello IN A 1.1.1.33 2.3.新增子域a.itnetcn.com的named.conf文件 如果子域无法的解析所有非本地域名,请将转发器指向主域itnetcn.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.itnetcn.com" { type master; file "a.itnetcn.com.zone"; }; 2.4.新增子域a.itnetcn.com的正向区域文件 vim /var/named/a.itnetcn.com,新增如下内容: $TTL 600 a.itnetcn.com. IN SOA ns1.a.itnetcn.com. root.a.itnetcn.com. ( 20160516 1H 10M 3D 1D ) a.itnetcn.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.如果子域无法解析itnetcn.com主域名,请将转发器指向主域itnetcn.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.itnetcn.com" { type master; file "a.itnetcn.com.zone"; }; zone "itnetcn.com" { type forward; forward first; forwarders { 1.1.1.18; }; }; 请注意,forward和forwarders放置位置不同,达到的效果不一样,一个放在options中,另一外放在zone命令单元中,请看仔细了,哈! (责任编辑:IT) |