bind 配置簡單自用 DNS 伺服器,binddns

來源:互聯網
上載者:User

bind 配置簡單自用 DNS 伺服器,binddns

目標:自訂一個網域名稱 www.test.com,可以解析到指定機器

 

安裝(版本:9.7.3):

yum install bind

 

配置:

初始化配置:

#產生rndc.conf檔案

cd /etc
rndc-confgen > rndc.conf
#產生named.conf檔案
tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf

#這之後 named.conf 內容看起來是這樣子:

key "rndc-key" {

algorithm hmac-md5;
secret "Bvqc7XRIJlz3s6p0JQ4Gwg==";
};

controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};

 

追加下面內容到 /etc/named.conf

options {
  directory "/var/named";
  forwarders { 192.168.1.1; }; # 無法解析的網域名稱轉到這裡
  allow-query { any; };
  # allow-transfer { none; };
};

# 下面那個處理 localhost

 

zone "localhost" {
  type master;
  file "named.localhost";
};

# localhost 反向解析

zone "0.0.127.in-addr.arpa" {
  type master;
  file "named.loopback";
};

# 我們自己的網域名稱

zone "test.com" IN {
  type master;
  file "test.zone";
  allow-update { none; };
};

 

目錄 /var/named 下添加一個設定檔 test.zone,內容如下:

$ttl 1D
@ IN SOA test.com. root.test.com. (
1053891162
3H
15M
1W
1D )
IN NS ns1
ns1 IN A 192.168.0.1
www IN A 192.168.0.3

 

配置完成,啟動服務:service named start

測試:

host www.test.com

 

擴充一下,配置bind主從,很簡單

拷貝主DNS的 /etc/named.conf 到從dns伺服器,相應的網域名稱配置中

zone "test.com" IN {

        type master;

        file "test.zone";

        allow-update { none; };

        };

改為(紅字部分)

zone "test.com" IN {

        type slave;

        file "test.zone";

        allow-update { none; };

        masters {dns地址;};

};

更新主dns後,重啟輔 dns 就會自動更新,不需要同步 test.zone 檔案

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.