Nslookup 命令行示例

现在 nslookup 已安装,请尝试以下一些命令以了解其工作原理。

要查看有关域 A 记录的基本信息,只需将域名指定为参数即可。
输出可能包含多个 IP 地址,具体取决于查询服务器的配置。

$nslookup redhat.com
Server:		127.0.0.53
Address:	127.0.0.53#53
Non-authoritative answer:
Name:	redhat.com
Address: 209.132.183.105

我们还可以通过指定 IP 地址并查看它指向的域名来查找反向 DNS 记录。

$nslookup 209.132.183.105
105.183.132.209.in-addr.arpa	name = redirect.redhat.com.

要查看域的邮件记录 (MX),请使用 -query=MX选项。
此记录控制发送到域(在本例中为 @redhat.com)的邮件将发送到何处。

$nslookup -query=mx redhat.com
Server:		127.0.0.53
Address:	127.0.0.53#53
Non-authoritative answer:
redhat.com	mail exchanger = 10 us-smtp-inbound-2.mimecast.com.
redhat.com	mail exchanger = 10 us-smtp-inbound-1.mimecast.com.

使用 -query=ns选项查看域的 DNS 服务器列表。

$nslookup -type=ns redhat.com
Server:		127.0.0.53
Address:	127.0.0.53#53
Non-authoritative answer:
redhat.com	nameserver = a10-65.akam.net.
redhat.com	nameserver = a9-65.akam.net.
redhat.com	nameserver = a13-66.akam.net.
redhat.com	nameserver = a28-64.akam.net.
redhat.com	nameserver = a1-68.akam.net.
redhat.com	nameserver = a16-67.akam.net.

这些是 nslookup 的一些主要选项,尽管有更多可用的查询类型和更多选项。
查看手册页以获取更多详细信息。

$man nslookup
$man dig

安装 nslookup

nslookup 很有可能已经安装在系统上并且可以使用了。
但是,如果没有,只需使用下面的适当命令来安装它。

要在 Ubuntu、Debian、Linux Mint 和任何其他基于 Debian 的发行版上安装 nslookup:

$sudo apt install dnsutils

要在 CentOS、Fedora、Red Hat 和任何其他基于 Red Hat 的发行版上安装 nslookup:

$sudo dnf install bind-utils

要在 Manjaro、Arch Linux 和任何其他基于 Arch Linux 的发行版上安装 nslookup:

$sudo pacman -S dnsutils
Nslookup Linux 命令

可以在 Linux 系统上安装和使用 nslookup实用程序,以查找有关域或者 IP 地址的 DNS 记录的信息。

在解决 DNS 问题时,它特别方便。
与 nslookup 一起安装的一个流行工具是 dig,它类似但使用不同的解析器。
它是 nslookup 的一个很好的替代品,但 nslookup 通常更易于使用。

日期:2020-07-07 20:56:52 来源:oir作者:oir