Linux nslookup命令帮助和DNS查找示例


本文摘自PHP中文网,作者不言,侵删。

nslookup代表“名称服务器查找”,是从DNS服务器获取信息的有用命令。它对于解决与DNS相关的问题也非常有用,可以查询到DNS(域名服务器)并获取IP地址的任何域的DNS记录。

DNS查找示例

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

1

# nslookup google.com

1

2

3

4

5

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

Name:   google.com

Address: 216.58.219.206

反向DNS查找

还可以使用ip地址进行反向dns查找,可以将使用IP地址解析相应的域。需要注意的是,这是在域的反向区域中配置的不同记录。

1

# nslookup 216.58.219.206

1

2

3

4

5

6

7

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

206.219.58.216.in-addr.arpa     name = lga25s40-in-f14.1e100.net.

206.219.58.216.in-addr.arpa     name = lga25s40-in-f14.1e100.net.

206.219.58.216.in-addr.arpa     name = lga25s40-in-f206.1e100.net.

206.219.58.216.in-addr.arpa     name = lga25s40-in-f206.1e100.net.

查询特定的DNS服务器

还可以查询特定的DNS服务器。需要为名称服务器IP地址或域名传递其他参数。例如,要查询到8.8.4.4名称服务器,使用的是以下命令。

1

# nslookup google.com 8.8.4.4

1

2

3

4

5

Server:         8.8.4.4

Address:        8.8.4.4#53

Non-authoritative answer:

Name:   google.com

Address: 216.58.219.206

查找域的SOA记录

使用nslookup查找任何域的SOA(授权开始)记录。例如,要查找域google.com的SOA记录,可以使用以下命令。需要指定type-type=soa作为命令行参数。

1

# nslookup -type=soa google.com

1

2

3

4

5

6

7

8

9

10

11

12

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

google.com

        origin = ns4.google.com

        mail addr = dns-admin.google.com

        serial = 159912615

        refresh = 900

        retry = 900

        expire = 1800

        minimum = 60

Authoritative answers can be found from:

origin:信息来源的权威。

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

serial:域的区域的修订数据,格式为YYYYMMDDNN。

refresh:辅助名称服务器将检查主名称服务器以获取区域的更新版本的referh间隔(以秒为单位)。

retry:在尝试失败后尝试重新连接到主名称服务器之前,等待次名称服务器的时间。

expire:辅助名称服务器缓存过期的时间(以秒为单位)。

minimum:如果自上次刷新以来没有经过时间,则不应刷新辅助名称服务器的缓存的时间(以秒为单位)。

查找域的MX记录

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

1

# nslookup -query=mx google.com

1

2

3

4

5

6

7

8

9

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

google.com      mail exchanger = 10 aspmx.l.google.com.

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 = 20 alt1.aspmx.l.google.com.

Authoritative answers can be found from:

查找域的TXT记录

TXT记录对于多种类型的记录(如DKIM、SPF等)很有用。您可以使用下面的命令查找为任何域配置的所有TXT记录。

1

# nslookup -query=txt google.com

1

2

3

4

5

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

google.com      text = "v=spf1 include:_spf.google.com ~all"

Authoritative answers can be found from:

查找域的所有记录

使用-query=any列出任何域的所有记录。

1

# nslookup -query=any google.com

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

Server:         8.8.8.8

Address:        8.8.8.8#53

Non-authoritative answer:

Name:   google.com

Address: 216.58.219.206

google.com      has AAAA address 2607:f8b0:4006:80e::200e

google.com      mail exchanger = 20 alt1.aspmx.l.google.com.

google.com      mail exchanger = 40 alt3.aspmx.l.google.com.

google.com      nameserver = ns2.google.com.

google.com      nameserver = ns4.google.com.

google.com      nameserver = ns3.google.com.

google.com      rdata_257 = 0 issue "pki.goog"

google.com      mail exchanger = 30 alt2.aspmx.l.google.com.

google.com      mail exchanger = 10 aspmx.l.google.com.

google.com      mail exchanger = 50 alt4.aspmx.l.google.com.

google.com      text = "v=spf1 include:_spf.google.com ~all"

google.com      nameserver = ns1.google.com.

google.com      rdata_257 = 0 issue "symantec.com"

google.com

        origin = ns2.google.com

        mail addr = dns-admin.google.com

        serial = 159912615

        refresh = 900

        retry = 900

        expire = 1800

        minimum = 60

Authoritative answers can be found from:

Nslookup在交互模式下

我们也可以在交互模式中使用nslookup。要进入交互模式,请在控制台上输入nslookup,然后按Enter。将得到nslookup提示,如>。在这里,可以运行相同的查询并从DNS服务器获取域的信息。为了更好的理解,在命令之间添加了注释。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

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:

本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注php中文网的其他相关栏目教程!!!

以上就是Linux nslookup命令帮助和DNS查找示例的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

Linux如何查看用户属于哪个组

怎么运行Linux程序

在不更换操作系统镜像的情况下如何扩大系统盘容量

Linux ping不通网关怎么办

为什么黑客都用Linux

嵌入式Linux实时操作系统及应用编程

10个可以提高效率的Linux命令别名

Linux难学么

Linux与android的区别

Linux下shell如何获取某目录下所有文件夹的名称详解

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...