人心不同 各如其面 如之奈何 如之奈何
——引子
我们的目标很明了——构建一个具有根的、私有的DNS(Domain Name System)。
这里不会陈述太多关于DNS与BIND的基础知识,如果您需要查看一些基础性的文章,文章末尾附录之中有传送门。
上图摘自《DNS与BIND》中文第四版。
上图便是我们整个DNS系统的鸟瞰,您需要特别注意,由于我们整个过程需要启动6个相互关联的、位于GNU/Linux操作系统上的DNS服务器,一个小小的失误,极可能导致最终的失败,所以,在接下来的“游戏”里,您应该时刻知道我们目前处于系统的哪个位置。
此次实验共有6台服务器参与,他们皆位于VMnet2:192.168.31.0/24网络中,当然,如果加上Host主机,就是7台。
Host主机的IP地址默认为192.168.31.1,我们将Clone 1的IP设置为192.168.31.98,他将担负根DNS服务器的职责。Clone 2至Clone 6便直接对应设置为192.168.31.2依次至192.168.31.6。
下面,我们便开始此次游历。
Step root:
目前位置——服务器Clone 1,192.168.31.98,职能为根DNS服务器。
各配置文件如下。
# /etc/named.conf
acl listen_acl
{
any;
};
acl allow_query_acl
{
any;
};
acl allow_recursion_acl
{
none; # allow_recursion none
};
acl allow_transfer_acl
{
none;
};
acl allow_update_acl
{
none;
};
options
{
listen-on port { listen_acl; };
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 { allow_query_acl; };
allow-recursion { allow_recursion_acl; };
allow-transfer { allow_transfer_acl; };
allow-update { allow_update_acl; };
}; zone "." IN {
type master; #master
file "root.zone";
};
# /var/named/root.zone
. IN SOA dns-.dns.mil. dns.mail.dns.mil. . IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98 cc. IN NS dns-cc-.dns.cc.
dns-cc-.dns.cc. IN A 192.168.31.3
org. IN NS dns-org-.dns.org.
dns-org-.dns.org. IN A 192.168.31.3 ;根域划分 子域授权
确认、启动根DNS服务。
Step cc & Step org:
目前位置——*域DNS服务器Clone 3,192.168.31.3,我们将cc与org域的DNS服务皆放在Clone 3服务器上,其将担负*域DNS服务器的职能。
各配置文件如下。
# /etc/named.conf
acl listen_acl
{
any;
};
acl allow_query_acl
{
any;
};
acl allow_recursion_acl
{
none;
};
acl allow_transfer_acl
{
none;
};
acl allow_update_acl
{
none;
};
options
{
listen-on port { listen_acl; };
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 { allow_query_acl; };
allow-recursion { allow_recursion_acl; };
allow-transfer { allow_transfer_acl; };
allow-update { allow_update_acl; };
};
zone "." IN {
type hint; #hint
file "root.cache"; #指定root DNS服务器的IP地址与FQDN
};
zone "cc" IN {
type master;
file "cc.zone";
};
zone "org" IN {
type master;
file "org.zone";
};
# /var/named/root.cache
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
# /var/named/cc.zone
$TTL cc. IN SOA dns-cc-.dns.cc. dns-cc.mail.dns.cc. ( 3H
15M
3D
1D
); cc. IN NS dns-cc-.dns.cc.
dns-cc-.dns.cc. IN A 192.168.31.3 eecs.cc. IN NS dns.eecs.cc.
dns.eecs.cc. IN A 192.168.31.4
# /var/named/org.zone
$TTL org. IN SOA dns-org-.dns.org. dns-org.mail.dns.org. ( 3H
15M
3D
1D
); org. IN NS dns-org-.dns.org.
dns-org-.dns.org. IN A 192.168.31.3 free.org. IN A 192.168.31.3 just.org. IN NS dns.just.org.
dns.just.org. IN A 192.168.31.5
确认、启动*域DNS服务。
Step eecs.cc:
目前位置——eecs.cc域DNS服务器Clone4,192.168.31.4。
各配置文件如下。
# /etc/named.conf
# /etc/named.conf
acl listen_acl
{
any;
};
acl allow_query_acl
{
any;
};
acl allow_recursion_acl
{
none;
};
acl allow_transfer_acl
{
none;
};
acl allow_update_acl
{
none;
};
options
{
listen-on port { listen_acl; };
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 { allow_query_acl; };
allow-recursion { allow_recursion_acl; };
allow-transfer { allow_transfer_acl; };
allow-update { allow_update_acl; };
}; zone "." IN {
type hint;
file "root.cache";
};
zone "eecs.cc" IN {
type master;
file "eecs.cc.zone";
};
# /var/named/root.cache
; /var/named/root.cache
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
# /var/named/eecs.cc.zone
; /var/named/eecs.cc.zone
$TTL eecs.cc. IN SOA dns.eecs.cc. dns.mail.eecs.cc. ( 3H
15M
3D
1D
); eecs.cc. IN NS dns.eecs.cc.
dns.eecs.cc. IN A 192.168.31.4 eecs.cc. IN A 192.168.31.4
mail.eecs.cc. IN A 192.168.31.4
www.eecs.cc. IN A 192.168.31.4
ftp.eecs.cc. IN A 192.168.31.4
cs.eecs.cc. IN A 192.168.31.4
确认、启动eecs.cc域DNS服务。
Step just.org:
目前位置——just.org域DNS服务器Clone 5,192.168.31.5。
各配置文件如下。
# /etc/named.conf
# /etc/named.conf
acl listen_acl
{
any;
};
acl allow_query_acl
{
any;
};
acl allow_recursion_acl
{
none;
};
acl allow_transfer_acl
{
none;
};
acl allow_update_acl
{
none;
};
options
{
listen-on port { listen_acl; };
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 { allow_query_acl; };
allow-recursion { allow_recursion_acl; };
allow-transfer { allow_transfer_acl; };
allow-update { allow_update_acl; };
}; zone "." IN {
type hint;
file "root.cache";
};
zone "just.org" IN {
type master;
file "just.org.zone";
};
# /var/named/root.cache
; /var/named/root.cache
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
# /var/named/just.org.zone
; /var/named/just.org.zone
$TTL just.org. IN SOA dns.just.org. dns.mail.just.org. ( 3H
15M
3D
1D
); just.org. IN NS dns.just.org.
dns.just.org. IN A 192.168.31.5 www.just.org. IN A 192.168.31.5
mail.just.org. IN A 192.168.31.5
确认、启动just.org域DNS服务。
Step DNS Server:
目前位置——递归DNS服务器Clone 6,192.168.31.6,此服务器直接向用户提供DNS服务。
各配置文件如下。
# /etc/named.conf
acl listen_acl
{
any;
};
acl allow_query_acl
{
any;
};
acl allow_recursion_acl
{
any; # allow_recursion any
};
acl allow_transfer_acl
{
none;
};
acl allow_update_acl
{
none;
};
options
{
listen-on port { listen_acl; };
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 { allow_query_acl; };
allow-recursion { allow_recursion_acl; };
allow-transfer { allow_transfer_acl; };
allow-update { allow_update_acl; }; }; zone "." IN {
type hint;
file "root.cache";
};
# /var/named/root.cache
; /var/named/root.cache
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
. IN NS dns-.dns.mil.
dns-.dns.mil. IN A 192.168.31.98
确认、启动递归DNS服务。
至此,整个系统构建完成。
我们使用Clone 2主机对我们的DNS系统进行测试。
1.编辑/etc/resolv.conf文件,已达到设置系统默认nameserver的目的;
2.进行测试,结果如下图:
附录:
基础资料传送门:http://www.cnblogs.com/smilenana/p/3414077.html http://www.cnblogs.com/xiaoluo501395377/tag/CentOS/