bind 9.0 view 實例

建立日期:2006/02/10
作者:csc@ocean-pioneer.com

這是9.0版所附的新功能
dns 伺服器會自動根據client端來回應,如下圖,兩個不同的要求回覆不同的IP


1.它可以作頻寬分流
2.分開lan,wan的查詢結果
還有其它功能可以自己發掘

mail server 範例



雖然網路上有範例,但並沒說明到一些重點,
因此我設定一直無法成功,直到我看到下面在網路上範例

Example named.conf

acl "dns_slaves" {
172.16.1.2; # IP of the slave DNS nameserver
172.16.101.2 # ditto
};
acl "lan_hosts" {
192.168.0.0/24; # network address of your local LAN
127.0.0.1; # allow loop back
};
options { # this section sets the default options
directory "/etc/namedb" # directory where the zone files will reside
listen-on {
192.168.0.1; # IP address of the local interface to listen
127.0.0.1; # ditto
};
auth-nxdomain no; # conform to RFC1035
allow-query { any; }; # allow anyone to issue queries
recursion no; # disallow recursive queries unless over-ridden below
version "0"; # obscures version reporting - can't hurt
};
key "rndc-key" {
        algorithm hmac-md5;
        secret "nOzUd7+Hwdq6k6CQq7SbDw=="; # DO NOT USE THIS KEY - example only
};
controls {
        inet 127.0.0.1 allow { localhost; }
        keys { rndc-key; };
};
view "internal" {
        match-clients { lan_hosts; }; # match hosts in acl "lan_hosts" above
        recursion yes; # allow recursive queries
        notify no; # disable AA notifies

        // prime the server with knowledge of the root servers
        zone "." {
                type hint;
                file "db.root";
        };
        // be authoritative for the localhost forward and reverse zones, and for
        // broadcast zones as per RFC 1912
        zone "localhost" {
                type master;
                file "db.local";
        };
        zone "127.in-addr.arpa" {
                type master;
                file "db.127";
        };
        zone "0.in-addr.arpa" {
                type master;
                file "db.0";
        };
        zone "255.in-addr.arpa" {
                type master;
                file "db.255";
        };
        zone "example.com" {
                type master;
                file "internal/example.com.zone";
        };
};
view "external" {

// "localnets" and "any" are special reserved words
// "localnets" mean any network address (as opposed to host address) configured
// on the local network interfaces - "!" means to negate
        match-clients { !localnets; any; };
        recursion no; # disallow recursive queries
        allow-transfer { dns_slaves; }; # allow "hosts in act "dns_slaves" to transfer zones

        zone "example.com" {
                type master;
                file "external/example.com.zone";
        };
};
 重點
#若要使用view,則所有的zone必須均在view的{}內

#同一個zone(如紅色example.com)根據不同的view你可以設定不同的結果
#acl是設定access control list ,可以加快及簡化設定
#! 代表相反
# any 代表任何IP

webmin 設定
使用webmin來設定
到bind設定->create view ,建立所有要用到的所有的view
到現存網域->進入網域->區域選項->move to view(選取你要分類到的view)


#必須將所有的網域分類到view的類別中
#名稱伺服器的重點是自己管理的網域,因此主要是分區域網路及網除網路#