DNS域名分离解析
1. 首先需要准备两张网卡
2.修改第二块网卡的IP地址等配置
这里我们用172.16.1.1做测试
#进入到网卡配置界面
vim /etc/sysconfig/network-scripts/ifcfg-eno33554968
修改项:
BOOTPROTO="static"
IPADDR=172.16.1.1
NETMASK=255.255.255.0
3.搭建DNS服务
#安装bind软件包
yum -y install bind
yum -y install bind
#修改指定DNS地址文件
vim /etc/resolv.conf
nameserver 192.168.200.111
nameserver 192.168.200.112
nameserver 192.168.200.113
vim /etc/resolv.conf
nameserver 192.168.200.111
nameserver 192.168.200.112
nameserver 192.168.200.113
#修改hosts文件
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.111 ns1.crushlinux.com
192.168.200.112 ns2.crushlinux.com
192.168.200.113 www.crushlinux.com
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.111 ns1.crushlinux.com
192.168.200.112 ns2.crushlinux.com
192.168.200.113 www.crushlinux.com
#修改主配置文件(实现分离解析)
vim /etc/named.conf
options {
directory "/var/named";
};
vim /etc/named.conf
options {
directory "/var/named";
};
view "LAN" {
match-clients { 192.168.200.0/24; };
zone "crushlinux.com" IN {
type master;
file "crushlinux.zheng.lan";
};
};
match-clients { 192.168.200.0/24; };
zone "crushlinux.com" IN {
type master;
file "crushlinux.zheng.lan";
};
};
view "WAN" {
match-clients { any; };
zone "crushlinux.com" IN {
type master;
file "crushlinux.zheng.wan";
};
};
match-clients { any; };
zone "crushlinux.com" IN {
type master;
file "crushlinux.zheng.wan";
};
};
#修改正向解析文件
vim /var/named/crushlinux.zheng.lan
\$TTL 86400
@ IN SOA crushlinux.com admin.crushlinux.com. (
123456
3H
15M
1W
1D
)
IN NS ns1.crushlinux.com.
IN NS ns2.crushlinux.com.
IN NS www.crushlinux.com.
IN MX 10 mail.crushlinux.com.
ns1 IN A 192.168.200.111
ns2 IN A 192.168.200.112
www IN A 192.168.200.113
ftp IN A 192.168.200.114
mail IN A 192.168.200.115
vim /var/named/crushlinux.zheng.lan
\$TTL 86400
@ IN SOA crushlinux.com admin.crushlinux.com. (
123456
3H
15M
1W
1D
)
IN NS ns1.crushlinux.com.
IN NS ns2.crushlinux.com.
IN NS www.crushlinux.com.
IN MX 10 mail.crushlinux.com.
ns1 IN A 192.168.200.111
ns2 IN A 192.168.200.112
www IN A 192.168.200.113
ftp IN A 192.168.200.114
mail IN A 192.168.200.115
#启动服务
systemctl restart named
systemctl enable named
systemctl enable named
5.给解析文件添加组权限
chgrp named crushlinux.zheng.wan
#重启服务
systemctl restart named
6.使用测试机进行测试
分别使用两个不同的网段
NAT网段
#设置IP地址和网关
#测试结果
VM2网段:
#测试结果