8个用于排查DNS(域名服务器)问题的Linux Nslookup命令

nslookup 是用于测试和故障排除 DNS 服务器(域名服务器)的命令行管理工具。它也用于查询特定的 DNS 资源记录(RR)。大多数操作系统都带有内置的 nslookup 功能。

本文详细介绍了广泛使用的 nslookup 命令。nslookup 可以以两种模式运行: 交互式非交互式

交互式 模式用于查询 DNS 服务器 关于各种域和主机的信息。 非交互式 模式用于查询有关域或主机的信息。

您可能也对以下文章感兴趣:

1. 查找域名的“A”记录(IP地址)

# nslookup yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
Name:   yahoo.com
Address: 72.30.38.140
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70

上述命令查询域名www.yahoo.com,使用4.2.2.2公共DNS服务器,下面的部分显示非权威回答:显示A记录的www.yahoo.com

2. 查找反向域名查找

# nslookup 209.191.122.70

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
70.122.191.209.in-addr.arpa     name = ir1.fp.vip.mud.yahoo.com.

Authoritative answers can be found from:

3. 查找特定域名查找

# nslookup ir1.fp.vip.mud.yahoo.com.

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
Name:   ir1.fp.vip.mud.yahoo.com
Address: 209.191.122.70

4. 查询MX(邮件交换)记录

# nslookup -query=mx www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827307
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

MX记录用于将域名映射到该域的邮件交换服务器列表。因此,它告诉您发送/接收到@yahoo.com的邮件将被路由到邮件服务器。

5. 查询NS(名称服务器)记录

# nslookup -query=ns www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827782
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

6. 查询SOA(权威起始)记录

# nslookup -type=soa www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827965
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

7. 查询所有可用的DNS记录

# nslookup -query=any yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
yahoo.com
        origin = ns1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 2012081016
        refresh = 3600
        retry = 300
        expire = 1814400
        minimum = 600
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70
Name:   yahoo.com
Address: 72.30.38.140
yahoo.com       mail exchanger = 1 mta7.am0.yahoodns.net.
yahoo.com       mail exchanger = 1 mta5.am0.yahoodns.net.
yahoo.com       mail exchanger = 1 mta6.am0.yahoodns.net.
yahoo.com       nameserver = ns3.yahoo.com.
yahoo.com       nameserver = ns4.yahoo.com.
yahoo.com       nameserver = ns2.yahoo.com.
yahoo.com       nameserver = ns8.yahoo.com.
yahoo.com       nameserver = ns1.yahoo.com.
yahoo.com       nameserver = ns6.yahoo.com.
yahoo.com       nameserver = ns5.yahoo.com.

Authoritative answers can be found from:

8. 启用调试模式

要启用调试模式,’set debug’将返回详细信息,例如TTL,以下是输出。

# nslookup -debug yahoo.com

> set debug
> yahoo.com
Server:         4.2.2.2
Address:        4.2.2.2#53

------------
    QUESTIONS:
        yahoo.com, type = A, class = IN
    ANSWERS:
    ->  yahoo.com
        internet address = 72.30.38.140
        ttl = 1523
    ->  yahoo.com
        internet address = 98.139.183.24
        ttl = 1523
    ->  yahoo.com
        internet address = 209.191.122.70
        ttl = 1523
    AUTHORITY RECORDS:
    ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name:   yahoo.com
Address: 72.30.38.140
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70

在本文中,我们尝试涵盖可帮助您搜索(DNS)域名服务相关信息的nslookup命令。

下一篇文章将是关于Linux dig 命令,它类似于 nslookup。如果你喜欢这篇文章,请与朋友分享,并别忘了通过评论框提供宝贵的反馈。

Source:
https://www.tecmint.com/8-linux-nslookup-commands-to-troubleshoot-dns-domain-name-server/