設置 DNS 分離解析可以對不同的客戶端提供不同的功能變數名稱解析記錄。來自不同地址的客戶機請求同一功能變數名稱時,為其提供不同的解析結果。 ...
設置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