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 命令的内容。敬请关注!

更新于:2019年10月18日

浏览量:320

开启你的 职业生涯

完成课程获得认证

开始学习
广告