泛解析
stuNUM.sail.com //NUM 是数字
# vim named.conf
zone "sail.com" {
type master;
file "sail.com.zone";
};
# vim sail.com.zone
$GENERATE 1-200 stu$ A 192.168.1.$
反向
$GENERATE 10-50 $ PTR stu$.uplooking.com.
/etc/resolv.conf//客户端指定哪个DNS服务器来为我解析域名
============
转发 caching
============
1、主服务器照常配置,能够解析正向、反向的区域配置文件
2、另外一台服务器装bind
* 在named.conf中添加两行
forwarders { 主服务器IP地址; };
forward only;
3、重启服务器 & 保证开机自动开启
----------------------------
DNS轮询:
[root@t1 etc]# vim named.conf
options {
directory "/var/named";
};
zone "aa.com" {
type master;
file "aa.com.zone";
};
[root@t1 named]# vim aa.com.zone
www IN A 192.168.20.251
www IN A 192.168.20.252
www IN A 192.168.20.253
实验结果:
一个FQDN对映多个IP,减轻只对一台服务器的访问压力。
练习
---------------------------
IP地址:192.168.1.X
1、搭建一个DHCP服务器
* 分配192.168.1.70 ~~~~192.168.1.170
* 所有DHCP客户端在获得IP地址的同时还能获取网关和DNS的信息
* 网关: 192.168.1.X
*DNS: 192.168.1.X
2、搭建一个DNS服务器
* 能够解析uplooking.com下的几个域名
* www ---> 本机
* client --->DHCP client
------------------------------------------------
子域授权:
在现实生活中我们世界互联网中的每个主机并不是在同一个域内,而是通过不同的依据将将其划分到不同的“小域”中,犹如一个倒立的树状结构,由一点出发,一层层的向下分成了多个分支,而这些分支就是其上级域的子域,其上级域就是相对的父域,子域是从父域中划出来的一个域,子域中的主DNS服务器负责这个子域中的地址解析,从而减轻了父域中DNS服务器的压力,这不仅提高了解析服务的效率,同样也提高了解析服务的稳定性。
服务器 uplooking.com8.8.8.8
Vm2 8.8.8.8
Vm1 192.168.10.1
打开路由转发 /etc/sysctl.confnet.ipv4.ip_forward = 1
# sysctl -p
# pwd
/var/named/chroot/etc
# vim named.conf
------------------------------------------------
options {
directory"/var/named";
};
zone "uplooking.com" IN {
type master;
file "uplooking.com.zone";
};
---------------------------------------
#pwd
/var/named/chroot/var/named
# cp –p localhost.zoneuplooking.com.zone
# vim uplooking.com.zone
-------------------------------
$TTL 86400
@ IN SOA uplooking.com. root.uplooking.com. (
42; serial
3H; refresh
15M; retry
1W; expiry
1D ); minimum
IN NS dns.uplooking.com.
dns.uplooking.com. IN A 8.8.8.8
zhuji.uplooking.com. IN NS dns.zhuji.uplooking.com.
dns.zhuji.uplooking.com. IN A 192.168.10.10
---------------------------------------------------------------------
#service named start
---------------------------------------------------------------------
子域 zhuji.uplooking.com192.168.10.10vm1
# yum install bind bind-chroot caching-nameserver -y
#pwd
/var/named/chroot/etc/
#vim named.conf
-----------------------------------------------
options {
directory "/var/named";
};
zone "zhuji.uplooking.com" IN {
type master;
file "zhuji.uplooking.com.zone";
};
-------------------------------------------
# cd /var/named/chroot/var/named/
# cp -p localhost.zone zhuji.uplooking.com.zone
# vim zhuji.uplooking.com.zone
------------------------------------------------------
$TTL 86400
@ IN SOA uplooking.com. root.uplooking.com. (
42; serial
3H; refresh
15M; retry
1W; expiry
1D ); minimum
IN NS dns.zhuji.uplooking.com.
dns IN A 192.168.10.10
www IN A 192.168.10.20
-----------------------------------------------------------
#service named start
测试
再开一台虚拟机 修改 /etc/resolv.conf添加
nameserver8.8.8.8
nslookupwww.zhuji.uplooking.com
DNS视图
用途:把不同来源的用户请求转向合适的地方,以提高整体访问速度。比如让网通线路的用户访问网通机房的服务器,电信用户访问电信机房的服务器。
Dns服务器端
有三块网卡,打开路由转发 /etc/sysctl.confnet.ipv4.ip_forward = 1
# sysctl -p
Vm1192.168.10.1
Vm8172.16.10.1
Vm28.8.8.8
# yum install bind bind-chroot caching-nameserver
# cd /var/named/chroot/etc
# cp -p named.caching-nameserver.confnamed.conf
# vim named.conf
//注意:acl的名字和view的名字不要用数字!
----------------------------------------------------------------------------
options {
directory"/var/named";
};
acl "unicom" { 172.16.10.0/24; };
acl "telcom" { 192.168.10.0/24; };
view "unicom" {
match-clients { unicom; };
recursion yes;
zone "uplooking.com" IN {
type master;
file "unicom.uplooking.com";
};
};
view "telcom" {
match-clients { telcom; };
recursion yes;
zone "uplooking.com" IN {
type master;
file "telcom.uplooking.com";
};
};
-------------------------------------------------------------------------
#vim /var/named/chroot/var/named/unicom.uplooking.com
# chown :named unicom.uplooking.com
# chmod 640 unicom.uplooking.com
--------------------------------------------------------
$TTL 86400
@ IN SOA uplooking.com. root.uplooking.com. (
42; serial (d. adams)
3H; refresh
15M; retry
1W; expiry
1D ); minimum
IN NS dns.uplooking.com.
dns IN A 8.8.8.8
www IN A 172.16.10.2
# cd /var/named/chroot/var/named
# cp -p unicom.uplooking.com telcom.uplooking.com
# vim telcom.uplooking.com
--------------------------------------------------------
$TTL 86400
@ IN SOA uplooking.com. root.uplooking.com. (
42; serial (d. adams)
3H; refresh
15M; retry
1W; expiry
1D ); minimum
IN NS dns.uplooking.com.
dns IN A 8.8.8.8
www IN A 192.168.10.2
----------------------------------------------------------------------------
测试:准备两台虚拟机
第一台网卡 vm1 ip地址 192.168.10.10 网关192.168.10.1
第二台网卡vm8 ip地址 172.16.10.10 网关172.16.10.1
在两台机器上 nslookupwww.uplooking.com看一下解析度IP地址是哪个网段的。