字體:  

原來 rndc 是這樣使用...

adj 發表於: 2007-11-29 17:49 來源: ADJ網路控股集團


轉貼自:Netman網中人

作者: Song (song) 看板: dns
標題: [測試] rndc.conf
時間: Sun Aug 26 10:22:43 2001

    Bind 9 的 rndc 就如同舊版的 ndc 是一樣的用途,
    而 rndc 的 'r' 是 remote 的意思,所以 rndc 還可以控管到
    遠端的 server 上去。

    rndc 需要設定 /etc/rndc.conf,且在 /etc/named.conf 上也需要配合,
    以本地端使用為例:

--- /etc/rndc.conf ---

key localhost {
        algorithm       "hmac-md5";
        secret  "SFhfWe9oUrOPkyNKExZWpg==";
};

options {
        default-server  localhost;
        default-key     localhost;
};

server localhost {
        key     localhost;
};

--- --- --- --- --- ---

    其中 key statement 裡的 secret  "SFhfWe9oUrOPkyNKExZWpg==";
    是用 dnssec-keygen 製作出來的,語法如下:

    dnssec-keygen -a hmac-md5 -b 128 -n HOST localhost

    這樣會得到 2 個檔案 :
    Klocalhost.+157+03077.key
    Klocalhost.+157+03077.private

# cat Klocalhost.+157+03077.key
localhost. IN KEY 512 3 157 SFhfWe9oUrOPkyNKExZWpg==

# cat Klocalhost.+157+03077.private
Private-key-format: v1.2
Algorithm: 157 (HMAC_MD5)
Key: SFhfWe9oUrOPkyNKExZWpg==

    這兩個檔案格式不同,但都可以看到用 HMAC_MD5 演算法產生的 secret
    然後將這組 secret 複製到 /etc/rndc.conf 的 key statement 裡去。

    接下來是 /etc/named.conf 裡需要配合的部分:

--- /etc/named.conf ---

key localhost {
        algorithm "hmac-md5";
        secret "SFhfWe9oUrOPkyNKExZWpg==";
};

controls {
        inet 127.0.0.1 allow { localhost; } keys { localhost; };
};

--- --- --- --- --- ---

    可以看到 /etc/named.conf 裡的 key statement 與 /etc/rndc.conf 的
    是一樣的。

    主要的是在 controls statement。
    在 IP (127.0.0.1) 之後沒有指定 port port_num 則內定值是 port 953。

    改完 /etc/named.conf 之後將 named 啟動,再來就可以用 rndc 了。
    在命令列輸入 rndc 不帶參數就會列出 usage :

# rndc
Usage: rndc [-c config] [-s server] [-p port]
        [-k key-file ] [-y key] [-V] command

command is one of the following:

  reload        Reload configuration file and zones.
  reload zone [class [view]]
                Reload a single zone.
  refresh zone [class [view]]
                Schedule immediate maintenance for a zone.
  reconfig      Reload configuration file and new zones only.
  stats         Write server statistics to the statistics file.
  querylog      Toggle query logging.
  dumpdb        Dump cache(s) to the dump file (named_dump.db).
  stop          Save pending updates to master files and stop the server.
  halt          Stop the server without saving pending updates.
  trace         Increment debugging level by one.
  trace level   Change the debugging level.
  notrace       Set debugging level to 0.
  flush         Flushes all of the server's caches.
  flush [view]  Flushes the server's cache for a view.
  status        Display status of the server.
  *restart      Restart the server.

* == not yet implemented
Version: 9.2.0