查询过程:
client-->local_dns_cache-->/etc/hosts-->first_dns(local_dns_cache-->/etc/hosts)-->first_dns | root_dns
那我们为什么要使用智能DNS服务器:1、因为不同ISP厂商有竞争,使得我们成为受害者,细心的网友一定会发现,南方的网友访问北方的网站一般都比较慢,北方的网友访问南方的网站也很慢。这些都是厂商之间的竞争导致的。
2、全区域访问量过于巨大,单组无法满足访问需求。想想去年铁路部的网站瘫痪就知道了,服务器根本无法承受来自全国各地的流量。所以单组是无法满足访问需求的。
教程开始:
1、在服务器上安装DNS软件
www.gupt12.com
192.168.254.100 dx
10.0.0.100 wt
# ifconfig eth0 192.168.254.100 --要添加两张网卡
# ifconfig eth0:0 10.0.0.100
# yum -y install bind
2、修改DNS的主配置文件,在主配置文件中定义两视图(电信(dx)/网通(wt))
# vim /etc/named.conf
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 { localhost; any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
#zone "." IN { --下面6行的#都是注释
# type hint;
# file "named.ca";
#};
#include "/etc/named.rfc1912.zones";
#include "/etc/named.root.key";
view dx {
zone "." IN {
type hint;
file "named.ca";
};
match-clients { 192.168.254.0/24; };
recursion yes;
include "/etc/named.rfc1912.zones";
zone "gupt12.com" {
type master;
file "/var/named/gupt12.com.dx";
};
};
view wt {
zone "." IN {
type hint;
file "named.ca";
};
match-clients { 10.0.0.0/24; };
recursion yes;
include "/etc/named.rfc1912.zones";
zone "gupt12.com" {
type master;
file "/var/named/gupt12.com.wt";
};
};
};
3、定义不同区域对应配置文件
# cd /var/named
# cp -a named.localhost gupt12.com.dx
# vim gupt12.com.dx
$TTL 1D
@ IN SOA dns.gupt12.com. root.gupt12.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gupt12.com.
dns IN A 192.168.254.100
www IN A 192.168.254.10
# cp -a gupt12.com.dx gupt12.com.wt
# vim gupt12.com.wt
$TTL 1D
@ IN SOA dns.gupt12.com. root.gupt12.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.gupt12.com.
dns IN A 10.0.0.100
www IN A 10.0.0.10
# named-checkconf /etc/named.conf --确保配置文件没有出错。
# named-checkzone gupt12.com.dx /var/named/gupt12.com.dx
zone gupt12.com.dx/IN: loaded serial 0
OK
# named-checkzone gupt12.com.wt /var/named/gupt12.com.wt
zone gupt12.com.wt/IN: loaded serial 0
OK
# service named start
4、测试智能DNS,是否能按不同客户端不同的结果
找两台客户机,一台电信,一台网通
电信客户机的解析结果:
# vim /etc/resolv.conf
nameserver 192.168.254.100
# nslookup
> www.gupt12.com
Server:192.168.254.100
Address:192.168.254.100#53
Name:www.gupt12.com
Address: 192.168.254.10
网通客户机的解析结果:
# nslookup
> server 10.0.0.100
Default server: 10.0.0.100
Address: 10.0.0.100#53
> www.gupt12.com
Server:10.0.0.100
Address:10.0.0.100#53
Name:www.gupt12.com
Address: 10.0.0.10