Linux nslookup 命令用於排查 DNS 域名伺服器
nslookup 是一個網路管理命令列工具,可在許多計算機作業系統上使用,用於查詢域名系統 (DNS) 以獲取域名或 IP 地址對映,或獲取任何其他特定 DNS 記錄。本文詳細解釋了 **nslookup** 命令。Nslookup 可以執行在兩種模式下:**互動式**和**非互動式**。**互動式**模式用於查詢 **DNS 伺服器** 的各種域名和主機。**非互動式**模式用於查詢域名或主機的相關資訊。
要查詢域名的“A”記錄(IP 地址),請使用以下命令:
$ sudo nslookup tutorialspoint.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: Name: tutorialspoint.com Address: 117.18.237.191
以上命令提供了關於 tutorialspoint.com 的資訊。非權威答案顯示了 Tutorialspoint.com 的記錄。
要進行反向域名查詢,請使用以下命令:
$ sudo nslookup 209.191.122.70
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: 70.122.191.209.in-addr.arpaname = UNKNOWN-209-191-122-X.yahoo.com. Authoritative answers can be found from:
要查詢 MX(郵件交換)記錄,請使用以下命令:
$ sudo nslookup -query=mx www.yahoo.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: www.yahoo.comcanonical name = fd-fp3.wg1.b.yahoo.com. Authoritative answers can be found from: wg1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1461733777 refresh = 30 retry = 30 expire = 86400 minimum = 300
MX 記錄用於將站點名稱對映到該區域的郵件交換伺服器記錄。基本上,它說明了傳送到/或接收到的任何@yahoo.com 的郵件將路由到哪個郵件伺服器。
要查詢 NS(名稱伺服器)記錄,請使用以下命令:
$ sudo nslookup -query=ns www.yahoo.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: www.yahoo.comcanonical name = fd-fp3.wg1.b.yahoo.com. Authoritative answers can be found from: wg1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1461734024 refresh = 30 retry = 30 expire = 86400 minimum = 300
要查詢 SOA(起始授權)記錄,請使用以下命令:
$ sudo nslookup -type=soa www.yahoo.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: www.yahoo.comcanonical name = fd-fp3.wg1.b.yahoo.com. Authoritative answers can be found from: wg1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1461734126 refresh = 30 retry = 30 expire = 86400 minimum = 300
要查詢所有可用的 DNS 記錄,請使用以下命令:
$ sudo nslookup -query=any yahoo.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: yahoo.comhas AAAA address 2001:4998:44:204::a7 yahoo.comnameserver = ns5.yahoo.com. yahoo.comnameserver = ns2.yahoo.com. yahoo.comnameserver = ns6.yahoo.com. yahoo.com origin = ns1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 2016042624 refresh = 3600 retry = 300 expire = 1814400 minimum = 600 yahoo.com has AAAA address 2001:4998:c:a06::2:4008 yahoo.com mail exchanger = 1 mta6.am0.yahoodns.net. yahoo.com mail exchanger = 1 mta5.am0.yahoodns.net. yahoo.com nameserver = ns4.yahoo.com. yahoo.com has AAAA address 2001:4998:58:c02::a9 yahoo.com nameserver = ns3.yahoo.com. yahoo.com nameserver = ns1.yahoo.com. yahoo.com mail exchanger = 1 mta7.am0.yahoodns.net. Authoritative answers can be found from:
要啟用 **除錯** 模式,請使用以下命令:
$ sudo nslookup -debug yahoo.com
示例輸出如下:
Server: 127.0.1.1 Address: 127.0.1.1#53 ------------ QUESTIONS: yahoo.com, type = A, class = IN ANSWERS: -> yahoo.com internet address = 206.190.36.45 ttl = 810 -> yahoo.com internet address = 98.139.183.24 ttl = 810 -> yahoo.com internet address = 98.138.253.109 ttl = 810 AUTHORITY RECORDS: ADDITIONAL RECORDS: ------------ Non-authoritative answer: Name:yahoo.com Address: 206.190.36.45 Name:yahoo.com Address: 98.139.183.24 Name:yahoo.com Address: 98.138.253.109
恭喜!現在您已經瞭解了“用於排查 DNS(域名伺服器)的 Linux Nslookup 命令”。我們將在下一篇文章中學習更多關於此類 Linux 命令的內容。敬請關注!
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP