如何在 Linux 中安装和使用 dig 和 nslookup 命令如何在 Linux 中安装和使用 dig 和 nslookup 命令如何在 Linux 中安装和使用 dig 和 nslookup 命令如何在 Linux 中安装和使用 dig 和 nslookup 命令
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Linux 中安装和使用 dig 和 nslookup 命令

在本文中,您将学习如何在 Linux 上安装 dig 命令和 nslookup 命令。这些命令用于网络故障排除和收集有关域名的信息。

Dig 是 Domain Information Gopher 的缩写,是一种 DNS 查找实用程序,用于探测 DNS 服务器并解决与 DNS 服务器相关的问题。由于其易于使用,系统管理员依赖该工具来解决 DNS 问题。

Nslookup 用于处理 DNS 查找并显示关键信息,例如 MX 记录以及与域名关联的 IP 地址。

较新的 Linux 系统默认附带 dig 和 nslookup 实用程序。然而,较旧的 Linux 系统可能不会。两者捆绑在 bind-utils 包中。

让我们看看如何在 Linux 中安装 DNS 故障排除实用程序。

在本页面:
  1. 在 CentOS/RHEL 中安装 dig 和 nslookup
  2. 在 Debian/Ubuntu 上安装 dig 和 nslookup
  3. 在 ArchLinux 上安装 dig 和 nslookup
  4. 使用挖掘命令
  5. 使用 nslookup 命令

在 CentOS/RHEL 中安装 dig 和 nslookup

在 Red Hat Linux /CentOS 上,使用 dnf 命令安装 dig 和 nslookup。

dnf install bind-utils

安装成功后,使用以下命令验证版本。

dig -v

在 Debian/Ubuntu 上安装 dig 和 nslookup

在 Debian 及其任何衍生版本(包括 Debian)上,安装是使用 apt 命令完成的。

apt install dnsutils

再次,要验证安装,请运行命令。

dig -v

在 ArchLinux 上安装 dig 和 nslookup

对于ArchLinux,安装dig和nslookup的命令是。

pacman -Sy dnsutils

要检查安装的 dig 版本,请运行。

dig -v

使用挖掘命令

dig 命令可用于查询域名并检索信息,如下所示:

dig fossmint.com

该命令显示大量信息,例如 dig 命令实用程序的版本、DNS 服务器及其相应的 IP 地址。

样本输出
; <<>> DiG 9.11.3-1ubuntu1.9-Ubuntu <<>> fossmint.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58049
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;fossmint.com.			IN	A

;; ANSWER SECTION:
fossmint.com.		300	IN	A	104.27.179.254
fossmint.com.		300	IN	A	104.27.171.254

;; Query time: 6 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Fri Nov 15 12:33:55 IST 2019
;; MSG SIZE  rcvd: 73

要获得更具体的信息并仅显示域名的 IP,请附加 +short 参数,如下所示:

dig fossmint.com +short

104.17.179.254
104.17.171.254

检查域名运行的MX记录。

dig fossmint.com MX +short

50 mx3.zoho.com.
20 mx2.zoho.com.
10 mx.zoho.com.

使用 nslookup 命令

要使用nslookup实用程序检索有关域名的信息,请使用以下命令。

nslookup fossmint.com
样本输出
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	fossmint.com
Address: 104.27.179.254
Name:	fossmint.com
Address: 104.27.171.254
Name:	fossmint.com
Address: 2606:4700:30::681b:b0fe
Name:	fossmint.com
Address: 2606:4700:30::681b:b1fe
结论

在本文中,您学习了如何在不同的 Linux 发行版中安装 dig 和 nslookup 命令实用程序以及这些命令的基本用法。我们确实希望您现在可以在遇到没有这些实用程序的系统时轻松安装这些实用程序。

©2015-2025 艾丽卡 support@alaica.com