linux的nslookup命令查询域名的帮助和例子

nslookup表示“域名查询”,对从域名服务器那获取是非常有用 的。它也非常有用的DNS相关问题的故障排除。它向DNS(域名服务器)查询,并获取IP地址的任何域的DNS记录。

在本教程中,您将得到nslookup命令在Linux服务器的一些有用的例子。此命令也可在Windows系统上使用。

DNS查询的例子

使用下面的命令查找域的地址记录。它查询域名服务器并获取详细信息。

nslookup google.com

Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
Name:   google.com
Address: 216.58.200.238

您还可以使用IP地址进行反向DNS查找。它将用IP地址解析相应的域名。请记住,这是在域反向区域中配置的不同记录。

nslookup 216.58.200.238

Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
238.200.58.216.in-addr.arpa     name = tsa03s01-in-f14.1e100.net.
238.200.58.216.in-addr.arpa     name = tsa03s01-in-f238.1e100.net.

Authoritative answers can be found from:
in-addr.arpa    nameserver = d.in-addr-servers.arpa.
in-addr.arpa    nameserver = e.in-addr-servers.arpa.
in-addr.arpa    nameserver = f.in-addr-servers.arpa.
in-addr.arpa    nameserver = a.in-addr-servers.arpa.
in-addr.arpa    nameserver = b.in-addr-servers.arpa.
in-addr.arpa    nameserver = c.in-addr-servers.arpa.

对特定DNS服务的查询

您还可以查询特定的DNS服务器。为此,您需要为名称服务器IP地址或域名传递附加参数。例如,查询10.0.2.3面的命令。

nslookup google.com 10.0.2.3

Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.24.14

查找域名记录

使用nslookup找到SOA(起始授权机构)的任何域名的记录。例如找到域名Google.com利用以下命令SOA记录。您需要指定type = SOA作为命令行参数。

vagrant@learning:~$ nslookup -type=soa google.com
Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
google.com
        origin = ns1.google.com
        mail addr = dns-admin.google.com
        serial = 160865928
        refresh = 900
        retry = 900
        expire = 1800
        minimum = 60

Authoritative answers can be found from:
google.com      nameserver = ns2.google.com.
google.com      nameserver = ns3.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns1.google.com.
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10

origin:信息来源的权威。

mail addr:该域的管理员的电子邮件地址(第一点代表“电子邮件地址符号)。

serial:修改数据区域的形式yyyymmddnn。

refresh:一refersh秒所在中学名称服务器将检查该区更新修订的主要名称服务器。

retry:等待时间为次域名服务器在试图重新连接到主域名服务器的尝试失败后。到期:为次域名服务器的缓存过期的时间秒。

minimum:在几秒钟的时间二级域名服务器的缓存不应该被刷新,如果时间没有过去刷新。

查找域的MX记录

您还可以查询任何域的MX(邮件交换)记录。这些域记录负责电子邮件传递。

vagrant@learning:~$  nslookup -query=mx google.com

Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.

Authoritative answers can be found from:
google.com      nameserver = ns3.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns1.google.com.
google.com      nameserver = ns2.google.com.
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10

查找域名的txt记录

txt记录用于记录像DKIM,SPF多类型是有用的,等你可以找到所有TXT记录配置为任何域使用下面命令。

vagrant@learning:~$ nslookup -query=txt google.com
Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
google.com      text = "v=spf1 include:_spf.google.com ~all"

Authoritative answers can be found from:
google.com      nameserver = ns2.google.com.
google.com      nameserver = ns3.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns1.google.com.
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10

查找域名的所有记录

vagrant@learning:~$ nslookup -query=any google.com
Server:         10.0.2.3
Address:        10.0.2.3#53

Non-authoritative answer:
google.com      rdata_257 = \# 19 0005697373756573796D616E7465632E636F6D
google.com      rdata_257 = \# 15 00056973737565706B692E676F6F67
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns1.google.com.
google.com      nameserver = ns2.google.com.
google.com      nameserver = ns3.google.com.

Authoritative answers can be found from:
google.com      nameserver = ns3.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns1.google.com.
google.com      nameserver = ns2.google.com.
ns1.google.com  internet address = 216.239.32.10
ns2.google.com  internet address = 216.239.34.10
ns3.google.com  internet address = 216.239.36.10
ns4.google.com  internet address = 216.239.38.10

在交互模式下使用nslookup

我们也可以在交互模式下使用nslookup。去互动模式控制台上按回车进行查询。你会像nslookup提示>。在这里,您可以运行相同的查询,并从DNS服务器获取域的信息。为了您的理解,我在命令之间添加了注释。

root@tecadmin:~# nslookup
### Type domain name to get information from dns server 
> google.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.10.46

### Set the another specific dns server to query. 
> server 8.8.4.4 
Default server: 8.8.4.4
Address: 8.8.4.4#53

### Again try to get the dns information, This time nslookup connects to specified dns server. 
> google.com 
Server:         8.8.4.4
Address:        8.8.4.4#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.10.46

### Set the query type. for example to get MX information set query=mx 
> set query=mx 

### Again try to get the dns information, This time nslookup will show MX information for domain 
> google.com 
Server:         8.8.4.4
Address:        8.8.4.4#53

Non-authoritative answer:
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.

Authoritative answers can be found from:
0 条评论
发表一条评论