溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Ubuntu 中怎么配置DNS服務(wù)器

發(fā)布時(shí)間:2021-07-13 14:28:58 來(lái)源:億速云 閱讀:650 作者:Leah 欄目:建站服務(wù)器

這篇文章給大家介紹Ubuntu 中怎么配置DNS服務(wù)器,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

DNS(Domain Name Server,域名服務(wù)器)是進(jìn)行域名(domain name)和與之相對(duì)應(yīng)的IP地址 (IP address)轉(zhuǎn)換的服務(wù)器。

Ubuntu 中怎么配置DNS服務(wù)器

環(huán)境說(shuō)明

服務(wù)器IP 10.68.19.61

操作系統(tǒng) Ubuntu 13.04

DNS程序 Bind9

測(cè)試域名 mycloud.com

目標(biāo)IP 10.68.19.134

安裝配置BIND9

apt-get install bind9

總共需要編輯2個(gè)文件,新增2個(gè)文件,如下: 修改/etc/bind/named.conf.options,去掉forwarders的注釋,其中的IP為網(wǎng)絡(luò)營(yíng)運(yùn)商提供的DNS服務(wù)器,這里我們使用google的DNS。

forwarders { 
       8.8.8.8; 
       8.8.4.4; 
};

修改/etc/bind/named.conf.local,在最后增加增加雙向解析代碼:

zone "mycloud.com" { 
     type master; 
     file "/etc/bind/db.mycloud.com"; 
}; 
   
zone "19.68.10.in-addr.arpa" { 
     type master; 
     file "/etc/bind/db.10.68.19"; 
};

注意:其中的19.68.10是目標(biāo)IP10.68.19.134的前三段,表示一個(gè)IP地址段。

新增域名(mycloud.com)解析文件/etc/bind/db.mycloud.com,內(nèi)容如下:

; 
; BIND data file for dev sites 
; 
$TTL    604800 
@       IN      SOA     mycloud.com. root.mycloud.com. ( 
                              1         ; Serial 
                         604800         ; Refresh 
                          86400         ; Retry 
                        2419200         ; Expire 
                         604800 )       ; Negative Cache TTL 
; 
@       IN      NS      mycloud.com. 
@       IN      A       10.68.19.134 
*.mycloud.com.  14400   IN      A       10.68.19.134

新增IP地址反向解析文件/etc/bind/db.10.68.19,內(nèi)容如下:

; 
; BIND reverse data file for dev domains 
; 
$TTL    604800 
@       IN      SOA     dev. root.dev. ( 
                              1         ; Serial 
                         604800         ; Refresh 
                          86400         ; Retry 
                        2419200         ; Expire 
                         604800 )       ; Negative Cache TTL 
; 
@        IN      NS      mycloud.com. 
134      IN      PTR     mycloud.com.

重啟BIND9服務(wù)

service bind9 restart

修改本機(jī)配置

修改每一臺(tái)需要使用該DNS服務(wù)器的dns配置文件

sudo vi /etc/resolv.conf

修改nameserver為上邊配置好的DNS服務(wù)器IP

nameserver 10.68.19.61

此修改在每次重啟服務(wù)器后都會(huì)賠覆蓋,可以修改配置文件

sudo vi /etc/resolvconf/resolv.conf.d/base

在其中增加一條

nameserver 10.68.19.61

這樣重啟服務(wù)器后DNS配置依然有效,然后重啟networking服務(wù),刷新DNS緩存。

service networking restart

測(cè)試效果

root@controller:/etc/bind# nslookup 
> baidu.com 
Server:         10.68.19.61 
Address:        10.68.19.61#53 
   
Non-authoritative answer: 
Name:   baidu.com 
Address: 220.181.111.86 
Name:   baidu.com 
Address: 123.125.114.144 
Name:   baidu.com 
Address: 220.181.111.85 
> mycloud.com 
Server:         10.68.19.61 
Address:        10.68.19.61#53 
   
Name:   mycloud.com 
Address: 10.68.19.134 
> uaa.mycloud.com 
Server:         10.68.19.61 
Address:        10.68.19.61#53 
   
Name:   uaa.mycloud.com 
Address: 10.68.19.134

關(guān)于Ubuntu 中怎么配置DNS服務(wù)器就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI