bind DNS 安裝與設定

以下是針對 CentOS 5.2 預設 bind 的安裝與設定來說明, 似乎在 CentOS 4.x 也可以適用

1 bind 安裝程序

yum install bind
  • CentOS 4.x 目前 bind 版本為 : 9.2.4-28
  • CentOS 5.x 目前 bind 版本為 : 9.3.4-6

2 bind 設定程序

  • 要產生 log 檔在 /var/log/named/named.log 內 語法
  • 讓 220.130.131.238 / 220.130.131.240 可以同步傳送存取
  • 有更動時可主動通知 192.168.11.250 / 192.168.11.251 這兩台的 DNS

vi /etc/named.conf

logging {
        channel Named_log {
                file "/var/log/named/named.log" versions unlimited;
                severity info;
                print-severity  yes;
                print-time yes; };
        category default {Named_log; };
        category xfer-out {Named_log; };
        category queries {Named_log; };
};

options {
        directory "/var/named";
        auth-nxdomain yes;
        recursion yes;
        allow-transfer {
                220.130.131.238;
                220.130.131.240;
        };
        allow-notify {
                192.168.11.250;
                192.168.11.251;
        };
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
};

3 內外 DNS 設定

3.1 /etc/named.conf

:
:

acl "lan" {
        192.168.11.0/24;
};

view "internal" {
        match-clients { lan; };
        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "ichiayi.com" {
                type master;
                file "data/internal.ichiayi.com";
                allow-transfer { none; };
        };
};

view "external" {
        match-clients { any; };

zone "." IN {
        type hint;
        file "named.ca";
};

:
:
zone "ichiayi.com" IN {
        type master;
        file "data/named.ichiayi.com";
        notify yes;
};
:
:
};

include "/etc/rndc.key";

3.2 /var/named/data/internal.ichiayi.com

;
;       ns1: /var/named/internal.ichiayi.com
;       Zone hosts file for internal of ichiayi.com
;
$TTL    86400
$ORIGIN ichiayi.com.
@               3H IN SOA       ns7.ichiayi.com. root.ichiayi.com. (
                                200811050234            ; serial (d. adams)
                                2H                      ; refresh
                                15M                     ; retry
                                1W                      ; expiry
                                12H )                   ; default_ttl (minimum)
                3H IN NS        ns7.ichiayi.com.
;
;       Mail exchanger
;
ichiayi.com.    IN      A       192.168.11.232
ichiayi.com. 0  IN      MX      10      mail.ichiayi.com.
:
web             IN      A       192.168.11.232
www             IN      CNAME   web
webmail         IN      CNAME   web
webmail         IN      CNAME   web
svn             IN      A       192.168.11.250
isms            IN      A       192.168.11.246
:

3.3 /var/named/data/named.ichiayi.com

;
;       ns1: /var/named/named.ichiayi.com
;       Zone hosts file for ichiayi.com
;
$TTL    86400
$ORIGIN ichiayi.com.
@               3H IN SOA       ns7.ichiayi.com. ns4.everplast.net. (
                                200811040420            ; serial (d. adams)
                                2H                      ; refresh
                                15M                     ; retry
                                1W                      ; expiry
                                12H )                   ; default_ttl (minimum)
                3H IN NS        ns7.ichiayi.com.
                3H IN NS        ns4.everplast.net.
;
;       Mail exchanger
;
ichiayi.com.    IN      A       122.116.133.14
ichiayi.com. 0  IN      MX      10      mail.ichiayi.com.
:
web             IN      A       122.116.133.14
www             IN      CNAME   web
webmail         IN      CNAME   web
svn             IN      CNAME   web
isms            IN      CNAME   web
:

設定預設名稱/萬用指向

因為有需求在網站上提供名稱網址功能, 所以無法在 DNS 上一一的定義所有網址名稱, 因此在 DNS 內設定預設名稱/萬用指向對應到特定的 ip 來達成這樣的目的, 設定方式其實也很簡單, 只要在 DNS 定義檔最後一行加入

:
;
*       IN      A       1.2.3.4

這樣所有在這 Domain Name 底下查詢不到的名稱, 就會有預設回覆對應的 1.2.3.4 IP

參考網址

 
回到頁頂
tech/bind.txt (3366) · 上一次變更: 2009-12-11 18:13 由 jonathan
 
 
CC Attribution-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0