7台主机模拟DNS架构
实验:在VMware虚拟机中开启7台主机模拟DNS架构
实验:在VMware虚拟机中开启7台主机模拟DNS架构
环境 :
操作系统:centos7.3、centos6.9、redhat5.4
网卡设为桥接模式,能互相连通
为方便排错,先建www-->主从服务器-->com-->根-->dns server-->client测试
解析过程:
ip为172.17.251.49的终端想访问www.magedu.com网站,它会先去问小区DNS服务器,如果小区DNS服务器上有www.magedu.com的DNS记录,就会将www.magedu.com解析成对应的ip返回给终端用户,如果如果小区DNS服务器上没有www.magedu.com的DNS记录,它会去问根服务器,根服务器会让它去问com服务器,com服务器让它去问magedu.com的主或者从服务器,小区服务器最终得到了www.magedu.com的ip地址,并把结果返回给用户终端。
1 www网站服务器
hostname www
vim /var/www/html/index.html 写一个简单的网页
<h1>www.magedu.com</h1>
2 magedu.com的DNS主服务器
hostnamectl set-hostname dnsmaster 修改主机名,方便识别
iptables -F 清除防火墙策略
setenforce 0 将SELinux设为警告状态
yum install bind 安装DNS软件
修改各个DNS服务器的DNS根文件,只留下实验设定的根ip:172.17.254.84
vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 172.17.254.88
将DNS指向自己的ip
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=172.17.251.177
systemctl resatrt network
cat /etc/resolv.conf 查看DNS是否指向自己
vim /etc/named.conf 修改DNS主配置文件
options {
listen-on port 53 { localhost; };
allow-query { any; };
allow-transfer { 172.17.254.167; };
dnssec-enable no;
dnssec-validation no;
};
named-checkconf 检查conf 文件是否存在语法错误
vim /etc/named.rfc1912.zones 修改DNS配置文件
zone "magedu.com" IN {
type master;
file "magedu.com.zone";
allow-update { none; };
};
参照模板创建解析库文件
cp -p /var/named/named.localhost /var/named/magedu.com.zone
vim /var/named/magedu.com.zone
$TTL 1D
@ IN SOA dns1 mail.magedu.com (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns1
@ NS dns2
dns1 A 172.17.251.177
dns2 A 172.17.254.167
www CNAME websrv
websrv A 172.17.251.166
重启DNS服务,加载配置文件
systemctl restart named
rndc reload
测试DNS是否设置成功
dig www.magedu.com @172.17.251.177
3 magedu.com的DNS从服务器
hostnamectl set-hostname slave
iptables -F
setenforce 0
yum install bind
修改各个DNS服务器的DNS根文件,只留下实验设定的根ip:172.17.254.84
vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 172.17.254.88
将DNS指向自己的ip
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=172.17.254.167
systemctl resatrt network
cat /etc/resolv.conf
vim /etc/named.conf
options {
//listen-on port 53 { 127.0.0.1; }; #//代表注释
//allow-query { localhost; };
allow-transfer {none;};
dnssec-enable no;
dnssec-validation no;
};
named-checkconf
vim /etc/named.rfc1912.zones
zone "magedu.com" IN {
type slave;
masters { 172.17.251.177; };
file "slaves/magedu.com.zone";
};
rndc reload
dig www.magedu.com @172.17.254.167
4 com DNS服务器
hostnamectl set-hostname com
iptables -F
setenforce 0
yum install bind
修改各个DNS服务器的DNS根文件,只留下实验设定的根ip:172.17.254.84
vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 172.17.254.88
vim /etc/named.conf
options {
//listen-on port 53 { 127.0.0.1; };
//allow-query { localhost; };
};
vim /etc/named.rfc1912.zones
zone "com" IN {
type master;
file "com.zone";
};
cp -p /var/named/named.localhost /var/named/com.zone
vim /var/named/com.zone
$TTL 1D
@ IN SOA dns1 admin (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns1
magedu NS dns2
magedu NS dns3
dns1 A 172.17.251.14
dns2 A 172.17.251.177
dns3 A 172.17.254.167
service named restart
rndc reload
dig www.magedu.com @172.17.251.14
5 根DNS服务器
hostnamectl set-hostname root
iptables -F
setenforce 0
yum install bind
修改各个DNS服务器的DNS根文件,只留下实验设定的根ip:172.17.254.84
vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 172.17.254.88
vim /etc/named.conf
options {
//listen-on port 53 { 127.0.0.1; };:
//allow-query { localhost; };
};
zone "." IN {
type master;
file "root.zone";
};
cp -p /var/named/named.localhost /var/named/root.zone
vim /var/named/root.zone
$TTL 1D
@ IN SOA dns1 mail.magedu.com (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns1
com NS dns2
dns1 A 172.17.254.88
dns2 A 172.17.251.14
service named restart
rndc reload
dig www.magedu.com
6 小区DNS服务器
hostname dnssrv
iptables -F
setenforce 0
yum install bind
v
修改各个DNS服务器的DNS根文件,只留下实验设定的根ip:172.17.254.84
vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 172.17.254.88
将DNS指向自己的ip
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=172.17.251.101
systemctl resatrt network
cat /etc/resolv.conf
vim /etc/named.conf
options {
//listen-on port 53 { 127.0.0.1; };:
//allow-query { localhost; };
dnssec-enable no;
dnssec-validation no;
};
named-checkconf
service named restart
rndc reload
dig www.magedu.com @172.17.251.101
7 客户端client
hostname client
[root@client ~]# vim /etc/resolv.conf
; generated by /sbin/dhclient-script
search magedu.com
nameserver 172.17.251.101
dig www.magedu.com #下图代表DNS搭建成功了
firefox www.magedu.com 可以看到www.magedu.com的网站页面,实验成功
更多推荐
所有评论(0)