關於Linux通過網域名稱解析ip問題

2021-10-12 01:43:40 字數 2993 閱讀 9419

linux下的網域名稱解析

問題:在/etc/hosts檔案下面配置如下

192.168.0.136 orderer0.example.com
ping orderer0.example.com還是報錯:unknown host orderer0.example.com, 大體意思是網域名稱解析失敗。

解決辦法如下:

命令安裝

sudo apt install bind9 //外網安裝命令
檢視狀態

sudo systemctl status bind9
啟動、停止、重啟命令

//啟動

sudo systemctl start bind9

//停止

sudo systemctl stop bind9

//重啟

sudo systemctl restart bind9

舉個例子,比如現在我們有個網域名稱是:example.com。現在我們要對這個網域名稱進行虛擬對映。

zone "example.com" ;
//

// 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 "example.com" ;

cd /etc/bind/         #進入該目錄

sudo mkdir zones #建立zones目錄

cd zones #進入zones目錄

touch example.com.db #建立example.com.db檔案

;;nd data file for example.com;;

$ttl 14400

@ in soa peer0.orga.example.com. host.example.com. (

201006601 ; serial

7200 ; refresh

120 ; retry

2419200 ; expire

604800 ;minimum

);default ttl;

example.com. in ns peer0.orga.example.com.

;example.com. in a 192.168.0.136

peer0.orga in a 192.168.0.136

orderer0 in a 192.168.0.136

couchdb.orga in a 192.168.0.136

ca.orga in a 192.168.0.136

peer0.org2 in a 192.168.0.136

peer0.org3 in a 192.168.0.136

couchdb1.orga in a 192.168.0.136

couchdb2.orga in a 192.168.0.136

couchdb3.orga in a 192.168.0.136

sudo systemctl restart bind9  //重啟
$ dig @192.168.0.136 couchdb.orga.example.com

; <<>> dig 9.10.3-p4-ubuntu <<>> @192.168.0.136 couchdb.orga.example.com

; (1 server found)

;; global options: +cmd

;; got answer:

;; ->>header<<- opcode: query, status: noerror, id: 141

;; flags: qr aa rd ra; query: 1, answer: 1, authority: 1, additional: 2

;; opt pseudosection:

; edns: version: 0, flags:; udp: 4096

;; question section:

;couchdb.orga.example.com. in a

;; answer section:

couchdb.orga.example.com. 14400 in a 192.168.0.136

;; authority section:

example.com. 14400 in ns peer0.orga.example.com.

;; additional section:

peer0.orga.example.com. 14400 in a 192.168.0.136

;; query time: 0 msec

;; server: 192.168.0.136#53(192.168.0.136)

;; when: wed dec 09 14:18:13 cst 2020

;; msg size rcvd: 105

;; query time: 0 msec

;; server: 192.168.0.136#53(192.168.0.136)

;; when: wed dec 09 14:18:13 cst 2020

;; msg size rcvd: 105

好了,這樣就表示已經配置成功了

Linux 網域名稱解析

1 本地dns解析 修改 etc hosts 檔案。etc hosts 檔案格式為 ip 網域名稱 如增加乙個新的解析為 2 網絡卡配置檔案dns服務位址 即修改網路配置資訊。如 etc sysconfig netword scripts ifcfg eth0 檔案 ifcfg eth0 為當前系統...

Linux 網域名稱解析

1 本地dns解析 修改 etc hosts 檔案。etc hosts檔案格式為 ip 網域名稱 如增加乙個新的解析為 223.231.234.33 www.baidu.com 2 網絡卡配置檔案dns服務位址 即修改網路配置資訊。如 etc sysconfig netword scripts if...

關於DNS網域名稱解析

首先簡單說一下dns的resource record 比如在cmd中執行ipconfig displaydns,你就會看到很多的resource record 下面主要談一下type 記錄型別.記錄型別有很多種,最常見的是a,ns,cname type a 那麼name 主機名,value 主機ip...