linux下bind9安裝配置一例

來源:互聯網
上載者:User

一,安裝BIND
1.下載BIND http://www.isc.org 也可以去本站下載 bind9 dns軟體。
2.編譯安裝

複製代碼 代碼如下:# tar zxvf bind-9.4.0.tar.gz
# cd bind-9.4.0
# ./configure sysconfdir=/etc //更多安裝選項 ./configure --help
# make
# make install

二,配置BIND
A.建立需要檔案
1)./etc/named.conf
# vi /etc/named.conf 推出儲存即可 或 touch /etc/named.conf

2)./etc/rndc.conf
# rndc-confgen > /etc/rndc.conf

B.建立目錄 /var/named
# mkdir /var/named

B.編輯/etc/named.conf 內容如下

複製代碼 代碼如下:options {
directory "/var/named"; //表示預設的資料庫檔案在/var/named中 若沒有需手動建立
// pid-file "/var/run/named/named.pid"; //啟動並執行PID檔案路徑,用於使用其他使用者啟動named
};
zone "." { //建立root域

type hint;
file "named.ca";
};
zone "localhost" { //建立 localhost域
type master;
file "named.local";
};
zone "example.com" { //建立 example.com域
type master;
file "example.com.zone";
};
zone "0.0.127.in-addr.arpa"{ //localhost的反解析
type master;
file "127.0.0.zone";
};
zone "100.168.192.in-addr.arpa" { //example.com的反向解析
type master;
file "192.168.100.zone";
};
//這段檔案在/etc/rndc.conf 的尾部需拷貝才能使用 # tail +13 /etc/rndc.conf >>/etc/named.conf
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
algorithm hmac-md5;
secret "HWM3L+e7LWDZJJ/dJEzQEw==";
};

controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
# End of named.conf

D.在/var/named 中建立相應的資料檔案 檔案名稱由named.conf 中的file 參數制定
由named.conf可知有 named.ca, named.local, example.com.zone, 127.0.0.zone , 192.168.100.zone
1. named.ca
# dig -t NS . >/var/named/named.ca
2. named.local #vi /var/named/named.local 加入以下內容

複製代碼 代碼如下:$TTL 1D
@ IN SOA localhost. root (
2007042801
1H
15M
1W
1D )
IN NS @
IN A 127.0.0.1

3. example.com.zone

複製代碼 代碼如下:$TTL 1D
@ IN SOA example.com. root (
2007042801
1H
15M
1W
1D )
IN NS ns.example.com.
IN MX 10 mail.example.com.
IN A 192.168.100.125
www IN A 192.168.100.125
db IN A 192.168.100.124
ns IN A 192.168.100.126
mail IN A 192.168.100.251
shop IN A 192.168.100.125
*.shop IN A 192.168.100.124
news IN CNAME www
3. 127.0.0.zone
$TTl 1D
@ IN SOA @ root.localhost. (
2007042801
1H
15M
1W
1D
)
IN NS localhost.
1 IN PTR localhost.
4. 192.168.100.zone
$TTL 1D
@ IN SOA @ root.example.com. (
2007042801
1H
15M
1W
1D )
IN NS example.com.
125 IN PTR example.com.
125 IN PTR www.example.com.
124 IN PTR db.example.com.
126 IN PTR ns.example.com.
251 IN PTR mail.example.com.

補充說明
a. named伺服器的啟動問題
1. 啟動 #named //以root使用者啟動
#named -u named //以named使用者啟動,必須有這個使用者而且,named.pid的屬主是 named
2. 更改配置後如何重啟
# rndc reload
3.測試組態是否成功,可用 host, dig ,nslookup 判斷

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.