ubuntu 靜態DNS配置

來源:互聯網
上載者:User

靜態DNS即網路的各台主機有固定IP,DNS記錄的主機與IP之間的映射是固定的。

首先安裝bind:sudo apt-get install bind9

 

這時在/etc/bind下會出現(這裡跟其他的UNIX/LINUX不同,一般其他的UNIX/LINUX預設是把設定檔放

在/etc/named下,資料檔案放在/var/named或/var/bind下的,而UBUNTU都一起放在這個目錄下了)

db.0 db.255 db.root named.conf.local
db.127 db.local named.conf named.conf.options

其中named.conf為主設定檔,named.conf.local和named.conf.options這兩個檔案在其他的UNIX/LINUX

系統裡預設是沒有的,UBUNTU的這種想法很不錯,把各個部分都分開管理;其餘的部分都是預設產生的幾

個資料檔案。這裡需要稍微講一下區資料檔案裡的幾個資源記錄的含義:

SOA記錄:指示該區的權威
NS記錄:列出該區的一個名字伺服器
A記錄:名字到地址的映射 (也就是正向解析)
PTR記錄:地址到名字的映射 (也就是反向解析)
CNAME:規範名字 (別名記錄)

接下來配置:我們只要更改named.conf.local檔案就ok了,ubuntu是建議不直接在named.conf直接配置的:

sudo vi /etc/bind/named.conf.local

添加如下:

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "15.117.202.in-addr.arpa"{
        type master;
        file "/etc/bind/db.202.117.15";
};

zone "test.com"{
        type master;
        file "/etc/bind/db.test.com";
};

建立db.test.com和db.202.117.15兩個檔案

sudo touch /etc/bind/db.202.117.15
sudo vi /etc/bind/db.202.117.15

修改:

;db.202.117.15
;
$TTL 604800
@ IN SOA ubuntu.test.com. root.ubuntu.test.com. (;配置目前範圍的DNS權威伺服器
                1; serial
                6040800;refresh
                86400;retry
                2419200;expire
                604800 );negative cache ttl;
@ IN NS ubuntu.test.com. ;我也不知道為什麼有個@,大家都這樣寫,就這樣寫啦,並且加個"."比較好,否則會出現後面翻譯的時候後面跟一串東西
165 IN PTR ubuntu.test.com.

db.test.com

sudo touch /etc/bind/db.test.com
sudo vi /etc/bind/db.test.com

修改:

; db.test.com
;
$TTL 604800
@ IN SOA ubuntu.test.com. root.ubuntu.test.com. (
                1;
                604800;
                86400;
                2419200;
                604800 );
@ IN NS ubuntu.test.com
ubuntu IN A 202.117.15.165;A後面不能跟的是名稱,即這種情況ubuntu IN A NS,在nslookup的時候會報錯。
www IN CNAME ubuntu

我們用nslookup測試,先把202.117.0.20和202.117.0.21關掉

xjtu129@xjtu129-desktop:/etc/bind$ nslookup
> ubuntu.test.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   ubuntu.test.com
Address: 202.117.15.165
> www.test.com
Server:         127.0.0.1
Address:        127.0.0.1#53

www.test.com    canonical name = ubuntu.test.com.
Name:   ubuntu.test.com
Address: 202.117.15.165
> 202.117.15.165
Server:         127.0.0.1
Address:        127.0.0.1#53

165.15.117.202.in-addr.arpa     name = ubuntu.test.com.15.117.202.in-addr.arpa.;出現後面一串東西就是因為之前沒有加“.”
>

聯繫我們

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