-----------------------------
概览
1.子域概念
2.实验环境准备
3.NS1配置
3.1 编辑主配置文件一
3.2 编辑主配置文件二
3.3. 区域配置文件
3.3.1 .正向区域文件
3.3.2修改属组
3.4 启动服务查看状态
4.NS2配置
4.1.编辑主配置文件一
4.2 编辑主配置文件二
4.3 区域配置文件
4.3 .1 正向区域文件
4.3.2修改属组
4.4. 启动服务查看状态
5.测试
5.1. 父域上测试
5.1.1.测试子域正向解析
5.1.2.解析本域
5.2 子域上测试
5.2.1测试父域正向解析
5.2.2测试本域正向解析
---------------------------------------
1.子域概念
子域名是个相对的概念,是相对父域名来说的。域名有很多级,中间用点分开。例如公司的顶级域名是以 com结尾的,所有以 com 结尾的域名便都是它的子域。例如:www.amaxit.net 便是 amaxit.net 的子域,而 amaxit.net 是 net的子域。类似一个家庭,孩子长大后又自己成立新的家庭,原来所长大的家庭是其父域,新成立的家庭为子域。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2.实验环境准备:
使用yum安装以下 |
软件: |
[[email protected] ~]# rpm-qa | grep bind
bind-license-9.9.4-18.el7_1.5.noarch
bind-libs-lite-9.9.4-18.el7_1.5.x86_64
bind-libs-9.9.4-18.el7_1.5.x86_64
bind-utils-9.9.4-18.el7_1.5.x86_64
bind-9.9.4-18.el7_1.5.x86_64
父域:
OS:Centos 7.1
hostname:ns1
Domain:zrd.com
IP:192.168.1.150
关闭firewalld与selinux
主机名对应的ip
dns |
192.168.1.150 |
www |
192.168.1.151 |
|
192.168.1.152 |
子域:
OS:Centos 7.1
hostname:ns2
Domain:src.zrd.com
IP:192.168.1.160
关闭firewalld与selinux
主机名对应的ip
dns |
192.168.1.160 |
www |
192.168.1.161 |
|
192.168.1.162 |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3.NS1配置
3.1 编辑主配置文件一
[[email protected] ~]# vim/etc/named.conf
options {
directory "/var/named";
options {
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; };
recursion yes; //
pid-file"/run/named/named.pid";
};
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";
#########################################################
3.2 编辑主配置文件二
[[email protected] ~]# vim/etc/named.rfc1912.zones
//named.rfc1912.zones:
//
// Provided by RedHat caching-nameserver package
//
// ISC BIND namedzone configuration for zones recommended by
// RFC 1912 section4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R WFranks
//
// See/usr/share/doc/bind*/sample/ for example named configuration files.
//
zone"localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone"localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone"1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone"0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
/////////////////////////////////
//自定义zrd.com正解的区域
////////////////////////////////
zone"zrd.com" IN {
type master;
file "zrd.com.zone";
};
###########################################################
3.3. 区域配置文件
3.3.1 .正向区域文件
[[email protected] ~]# vim/var/named/zrd.com.zone
$TTL 600
@ IN SOA dns.zrd.com. admin.zrd.com. (
2015091913
1H
5M
3D
12H
)
IN NS dns
IN MX 10 mail
dns2 IN A 192.168.1.200
dns IN A 192.168.1.150
www IN A 192.168.1.151
mail IN A 192.168.1.152
pop IN CNAME mail
src IN NS dns.src
dns.src IN A 192.168.1.160 //子域配置的关键点定义其主机名以及IP地址
############################
3.3.2 修改属组
[[email protected] named]# chown :named src.zrd.com.zone
3.3.3 启动服务查看状态
[[email protected] named]# systemctl start named
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
4.NS2配置
4.1. 编辑主配置文件一
[[email protected] named]#cat /etc/named.conf
options {
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; };
recursionyes;
pid-file"/run/named/named.pid";
};
logging {
channel default_debug {
file"data/named.run";
severity dynamic;
};
};
zone "."IN {
typehint;
file"named.ca";
};
include"/etc/named.rfc1912.zones";
//include"/etc/named.root.key";
#####################################################
4.2 编辑主配置文件二
[[email protected]]# vim/etc/named.rfc1912.zones
//named.rfc1912.zones:
//
// Provided by RedHat caching-nameserver package
//
// ISC BIND namedzone configuration for zones recommended by
// RFC 1912 section4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R WFranks
//
// See/usr/share/doc/bind*/sample/ for example named configuration files.
//
zone"localhost.localdomain" IN {
typemaster;
file"named.localhost";
allow-update{ none; };
};
zone"localhost" IN {
typemaster;
file"named.localhost";
allow-update{ none; };
};
zone"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"IN {
typemaster;
file"named.loopback";
allow-update{ none; };
};
zone"1.0.0.127.in-addr.arpa" IN {
typemaster;
file"named.loopback";
allow-update{ none; };
};
zone"0.in-addr.arpa" IN {
typemaster;
file"named.empty";
allow-update{ none; };
};
////////////////////////////
//子域服务器正解配置
////////////////////////////
zone"src.zrd.com" IN {
typemaster;
file"src.zrd.com.zone";
};
/////////////////////////
//父域服务器设置
/////////////////////////
zone"zrd.com" IN {
typeforward;
forwarders { 192.168.1.150; }; //解析zrd.com区域时转发到父域上,让其进行解析
forwardonly;
};
###############################################################################
4.3 区域配置文件
4.3 .1 正向区域文件
[[email protected] named]#vim /var/named/src.zrd.com.zone
$TTL 600
@ IN SOA dns.src.zrd.com. admin.src.zrd.com. (
2015091913
1H
5M
3D
12H
)
IN NS dns
IN MX 10 mail
dns IN A 192.168.1.160
www IN A 192.168.1.161
mail IN A 192.168.1.162
pop IN CNAME mail
4.3.2. 修改属组
[[email protected] named]#chown :named src.zrd.com.zone
4.4. 启动服务器查看状态
##############################################################################
5.测试
###############################################################
5.1. 父域上测试
5.1.1. 测试子域正向解析
[[email protected] ~]# host -t A www.src.zrd.com 192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: www.src.zrd.com has address 192.168.1.161 [[email protected] ~]# host -t A mail.src.zrd.com192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: mail.src.zrd.com has address 192.168.1.162 [[email protected] ~]# host -t A dns.src.zrd.com192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: dns.src.zrd.com has address 192.168.1.160
5.1.2. 解析本域
[[email protected] ~]# host -t A www.zrd.com 192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: www.zrd.com has address 192.168.1.151 [[email protected] ~]# host -t A dns.zrd.com 192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: dns.zrd.com has address 192.168.1.150 [[email protected] ~]# host -t A mail.zrd.com 192.168.1.150 Using domain server: Name: 192.168.1.150 Address: 192.168.1.150#53 Aliases: mail.zrd.com has address 192.168.1.152
##########################################
5.2 子域上测试
5.2.1 测试父域正向解析
[[email protected] named]#host -t A www.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: www.zrd.com has address 192.168.1.151 [[email protected] named]#host -t A mail.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: mail.zrd.com hasaddress 192.168.1.152 [[email protected] named]#host -t A dns.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: dns.zrd.com hasaddress 192.168.1.150
##########################################
5.2.2 测试本域正向解析
[[email protected] named]#host -t A dns.src.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: dns.src.zrd.com hasaddress 192.168.1.160 [[email protected] named]#host -t A www.src.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: www.src.zrd.com has address 192.168.1.161 [[email protected] named]#host -t A mail.src.zrd.com 192.168.1.160 Using domain server: Name: 192.168.1.160 Address:192.168.1.160#53 Aliases: mail.src.zrd.com hasaddress 192.168.1.162