centos7.4 dns 分离解析的简易剖析
一, 实验环境
一台配备双网卡的虚拟机, 使用仅主机模式. 地址分别是 ens33 IP:192.168.100.1 ens36 IP:12.0.0.1.. 安装 bind 包. 两台台 win7 虚拟机, 做客户端访问. 一台外网地址为 192.168.100.10, 一台内网 12.0.0.20.
这里双网卡一个做内网网关, ens33 做外网网关, ens36 做内网网关.
- yum install bind bind-utils -y
- vim /etc/named.conf // 编辑主配置文件
- listen-on port 53 {any;}; // 监听地址改为 any, 监听任何地址
- allow-query { any; }; // 允许 DNS 查询的客户端地址
将下面的根移动到区域配置文件
- zone "." IN {
- type hint;
- file "named.ca";
- };
- vim /etc/named.rfc1912.conf
- view "lan" {
- match-clients { 192.168.100.0/24;192.168.110.0/24; }; // 允许那个网段的能使用解析
- zone "benet.com" IN {
- type master;
- file "benet.com.zone.lan";
- };
- zone "." IN {
- type hint;
- file "named.ca";
- };
- };
- view "wan" {
- match-clients { any; };
- zone "benet.com" IN {
- type master;
- file "benet.com.zone.wan";
- };
- };
- [root@localhost ~]# cd /var/named/// 转到此路径下, 找到 named.localhost 文件
- [root@localhost named]# cp -p named.localhost benet.com.zone.lan
- [root@localhost named]# cp -p named.localhost benet.com.zone.wan
- // 保留权限复制
编辑新复制的文件:
vim benet.com.zone.lan
改为如下格式
- $TTL 1D
- @ IN SOA benet.com. admin.benet.com. (
- 0 ; serial
- 1D ; refresh
- 1H ; retry
- 1W ; expire
- 3H ) ; minimum
- NS benet.com.
- A 12.0.0.1
- www IN A 12.0.0.12
- vim benet.com.zone.wan // 编辑 wan 文件
改为以下格式
- $TTL 1D
- @ IN SOA benet.com. admin.benet.com. (
- 0 ; serial
- 1D ; refresh
- 1H ; retry
- 1W ; expire
- 3H ) ; minimum
- NS benet.com
- A 192.168.100.1
- www IN A 192.168.100.1
启动服务.
systemctl start named.service
用两台 win 7 验证.
命令
nslookup www.benet.com
可以得到解析地址.
来源: http://www.bubuko.com/infodetail-2718264.html