首页·终端命令

nslookup

网络

用法

nslookup <name> [server]

把名字解析成地址的老工具:它还能跑,但输出格式和退出状态都不稳定,写脚本没法用,如今这活由 dig 接了过去。

常用选项

选项含义
<name> <server>The resolver to ask goes second, with no flag.
-type=MXRecord type, written with an equals sign.
-debugShow the full packet, including the flags in the header.
(no argument)Drops into an interactive prompt where you use "set type=MX".

示例

nslookup example.com 1.1.1.1

A quick lookup against a chosen resolver.

nslookup -type=MX example.com

Mail records, the nslookup spelling.

连不上的时候,这些能把范围缩小——是名字解析不了、没有路由,还是端口被挡。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. nslookup 是做什么的?

把名字解析成地址的老工具:它还能跑,但输出格式和退出状态都不稳定,写脚本没法用,如今这活由 dig 接了过去。

Q. 怎么写?

nslookup <name> [server] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 4 个,完整列表在 man nslookup。这条命令属于网络。

相关命令

man 手册: man nslookup