view "internal-linux" {
match-clients { "linux"; };
zone "kaiiiz.nctucs.net" IN {
type master;
file "zone/db.kaiiiz.nctucs.net";
};
zone "184.229.35.in-addr.arpa" {
type master;
file "zone/db.35.229.184";
};
zone "sub.muller.nctucs.net" IN {
type master;
file "zone/db.sub.muller.nctucs.net.internal-linux";
notify yes;
};
zone "sub.kaiiiz.nctucs.net" IN {
type slave;
file "slaves/db.sub.kaiiiz.nctucs.net.linux";
masters { 35.229.252.239; };
};
};
以及在 bsd 的 view:
named.conf.local
view "internal-bsd" {
match-clients { "bsd"; };
zone "kaiiiz.nctucs.net" IN {
type master;
file "zone/db.kaiiiz.nctucs.net";
};
zone "184.229.35.in-addr.arpa" {
type master;
file "zone/db.35.229.184";
};
zone "sub.muller.nctucs.net" IN {
type master;
file "zone/db.sub.muller.nctucs.net.internal-bsd";
notify yes;
};
zone "sub.kaiiiz.nctucs.net" IN {
type slave;
file "slaves/db.sub.kaiiiz.nctucs.net.bsd";
masters { 35.229.252.239; };
};
};
還有其他的 query:
named.conf.local
view "otherwise" {
match-clients { any; };
zone "kaiiiz.nctucs.net" IN {
type master;
file "zone/db.kaiiiz.nctucs.net";
};
zone "184.229.35.in-addr.arpa" {
type master;
file "zone/db.35.229.184";
};
zone "sub.kaiiiz.nctucs.net" IN {
type slave;
file "slaves/db.sub.kaiiiz.nctucs.net";
masters { 35.229.252.239; };
};
zone "sub.muller.nctucs.net" IN {
type master;
file "zone/db.sub.muller.nctucs.net";
notify yes;
};
};
Default Zone with View
別忘了 named.conf.default-zones 裡面的也要改:
view "any" {
match-clients { any; };
zone "." {
type hint;
file "/etc/bind/db.root";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
};
Zone files
這裡我們多了幾個 zone file:
zone/db.sub.muller.nctucs.net.internal-linux
zone/db.sub.muller.nctucs.net.internal-bsd
slaves/db.sub.kaiiiz.nctucs.net.bsd
slaves/db.sub.kaiiiz.nctucs.net.linux
slaves 的兩個新的 zone files 因為是交由隊友託管所以不用管他,master 的兩個新的 zone files 基本上檔案的長相都跟 db.sub.muller.nctucs.net 一樣,只是可以設定來自不同 view 的 query 該回應哪個對應的 A record 如此
db.sub.muller.nctucs.net.internal-linux:
$TTL 600
@ IN SOA dns.kaiiiz.nctucs.net. admin.kaiiiz.nctucs.net. (
2018041607
1800
900
1W
1D )
@ IN NS dns.kaiiiz.nctucs.net.
@ IN NS dns.muller.nctucs.net.
demo IN CNAME ws.sub.muller.nctucs.net.
ns1 IN A 192.168.1.1
sub IN A 192.168.1.2
test IN A 192.168.1.3
ws.sub.muller.nctucs.net. IN A 140.113.235.151
db.sub.muller.nctucs.net.internal-bsd:
$TTL 600
@ IN SOA dns.kaiiiz.nctucs.net. admin.kaiiiz.nctucs.net. (
2018041607
1800
900
1W
1D )
@ IN NS dns.kaiiiz.nctucs.net.
@ IN NS dns.muller.nctucs.net.
demo IN CNAME ws.sub.muller.nctucs.net.
ns1 IN A 192.168.1.1
sub IN A 192.168.1.2
test IN A 192.168.1.3
ws.sub.muller.nctucs.net. IN A 140.113.235.131
可以觀察到與 db.sub.muller.nctucs.net.internal-bsd 的區別只在於 dig ws.sub.muller.nctucs.net 回應的 A 會不同
測試
View 測試
在系計中的 linux 和 bsd 工作站和外面 dig ws.sub.muller.nctucs.net 應該要回應不同的 A record