设置DNS分离解析可以对不同的客户端提供不同的域名解析记录。来自不同地址的客户机请求同一域名时,为其提供不同的解析结果。


安装 bind 包

[root@localhost ~]# yum install bind bind-utils -y

双网卡配置

两张网卡全部切换至仅主机模式。

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
  • 配置内网网关IP地址
[root@localhost network-scripts]# vim ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.1
NETMASK=255.255.255.0
  • 配置外网网关IP地址
[root@localhost network-scripts]# cp -p ifcfg-ens33 ifcfg-ens37
[root@localhost network-scripts]# vim ifcfg-ens37
TYPE=Ethernet
BOOTPROTO=static
DEVICE=ens37
ONBOOT=yes
IPADDR=12.0.0.1
NETMASK=255.255.255.0
  • 重启网络服务
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ OK ]
[root@localhost ~]# ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.1 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::20c:29ff:febc:ab96 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bc:ab:96 txqueuelen 1000 (Ethernet)
RX packets 1056 bytes 299717 (292.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 180 bytes 22441 (21.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# ifconfig ens37
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 12.0.0.1 netmask 255.255.255.0 broadcast 12.0.0.255
inet6 fe80::20c:29ff:febc:aba0 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bc:ab:a0 txqueuelen 1000 (Ethernet)
RX packets 1010 bytes 301554 (294.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 106 bytes 16880 (16.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

编辑主配置文件

[root@localhost ~]# vim /etc/named.conf
  • 配置监听网段、允许查询网段
listen-on port 53 { any; };
allow-query { any; };
  • 删除根的配置部分,放到区域配置文件中。
zone "." IN {
type hint;
file "named.ca";
};

编辑区域配置文件

[root@localhost ~]# vim /etc/named.rfc1912.zones

删除所有已存在的配置,添加以下配置

view "lan" {
match-clients { 192.168.100.0/24; };
zone "yun.com" IN {
type master;
file "yun.com.lan";
};
zone "." IN {
type hint;
file "named.ca";
};
}; view "wan" {
match-clients { 12.0.0.0/24; };
zone "yun.com" IN {
type master;
file "yun.com.wan";
};
};

编辑区域数据配置文件

[root@localhost ~]# cd /var/named/
  • 编辑lan区域数据文件
[root@localhost named]# cp -p named.localhost yun.com.lan
[root@localhost named]# vim yun.com.lan
$TTL 1D
@ IN SOA yun.com. admin.yun.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS yun.com.
IN A 192.168.100.1
www IN A 192.168.100.10
ftp IN A 192.168.100.20
  • 编辑wan区域数据文件
[root@localhost named]# cp -p yun.com.lan yun.com.wan
[root@localhost named]# vim yun.com.wan
$TTL 1D
@ IN SOA yun.com. admin.yun.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS yun.com.
IN A 12.0.0.1
www IN A 12.0.0.1
ftp IN A 12.0.0.1

启动服务

[root@localhost ~]# systemctl start named
[root@localhost ~]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.

结果测试

两台客户机的网络为仅主机模式。

内网win10测试

Microsoft Windows [版本 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved. C:\Users\ll>nslookup www.yun.com
服务器: UnKnown
Address: 192.168.100.1 名称: www.yun.com
Address: 192.168.100.10 C:\Users\ll>nslookup ftp.yun.com
服务器: UnKnown
Address: 192.168.100.1 名称: ftp.yun.com
Address: 192.168.100.20

外网win7测试

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\ll>nslookup www.yun.com
服务器: UnKnown
Address: 12.0.0.1 名称: www.yun.com
Address: 12.0.0.1 C:\Users\ll>nslookup ftp.yun.com
服务器: UnKnown
Address: 12.0.0.1 名称: ftp.yun.com
Address: 12.0.0.1

最新文章

  1. jQuery选择器总结
  2. C#3.0扩展方法学习篇
  3. Redhat Server 5.7 安装配置PHP
  4. NOIP2001 一元三次方程求解[导数+牛顿迭代法]
  5. centos7查看端口命令
  6. Codeforces Round #324 (Div. 2) C (二分)
  7. UIApplication的使用
  8. python 基础学习(字典对象,set对象)
  9. POJ2221+模拟
  10. Objective-C 中的方法回掉
  11. Android——ExpandableListView事件拦截
  12. js中style的属性
  13. Android:关于Edittext的一些设置
  14. 微信小程序-实战巩固(二)
  15. 使用swiper简单的h5下滑翻页效果,
  16. php GD库快速消耗CPU资源漏洞 CVE-2018-5711测试
  17. Python 魔法方法简介
  18. css技巧小计
  19. session(概念、session对象的获取、删除、验证)
  20. 实用ExtJS教程100例-007:ExtJS中Window组件最小化

热门文章

  1. VS找不到头文件但是系统路径已经设置
  2. Pi1-lite
  3. Python - Django - form 组件动态从数据库取 choices 数据
  4. 【转】kettle7.1资源库无法打开,找不到connect按钮的问题处理
  5. linux安装jira
  6. 【转】什么是5G?居然有人用漫画把它讲得如此接地气!
  7. 如何录制高清GIF格式的图片
  8. SpringBoot系列教程web篇之全局异常处理
  9. Mysql 查询时间段是否可用,查询时间段是否有交集
  10. PyGSP