0Pricing
Linux Command Line Mastery · 课时

网络诊断:`traceroute`、`nslookup`、`dig`

使用专用命令行工具进行高级网络故障排查和 DNS 查询。

网络诊断:`traceroute`、`nslookup`、`dig` 是 CoddyKit 上的免费 Linux Command Line Mastery 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Linux Command Line Mastery 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Linux Command Line Mastery 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Welcome to Network Diagnostics

Ever wonder why a website is slow or unreachable? Network diagnostics help you pinpoint issues!

In this lesson, we'll explore powerful command-line tools like traceroute, nslookup, and dig.

These tools help you understand network paths and resolve domain names.

Beyond Basic Connectivity

You might already know ping for checking if a host is reachable. But what if it's reachable but slow?

traceroute (or tracert on Windows) goes a step further. It maps the path your data takes to reach a destination.

Mapping the Network Path

traceroute sends small packets and measures the time it takes for each "hop" (router) along the way to respond.

  • Each line in the output represents a router.
  • It shows the IP address and latency (how long it took to respond).
  • This helps identify where delays or failures occur.

Your First Traceroute

To use traceroute, simply provide a hostname or IP address. Let's trace the path to example.com.

Note: You might need to install traceroute on some Linux systems (e.g., sudo apt install traceroute).

traceroute example.com

Deciphering Traceroute Results

The output shows numbered hops, each with a router's IP address and three latency measurements (in milliseconds).

  • Hop Number: The sequence in the path.
  • Latency: Time for the packet to reach that hop and return.
  • Asterisks (*): A hop that didn't respond, possibly due to a firewall.

High latency at a specific hop can indicate a bottleneck.

DNS: The Internet's Phonebook

When you type "google.com" into your browser, how does your computer know where to find it?

It uses the Domain Name System (DNS)! DNS translates human-readable domain names (like "google.com") into machine-readable IP addresses (like "142.250.190.14").

Basic `nslookup` Queries

nslookup is a simple tool to query DNS servers for information about domain names.

It's often used to find the IP address associated with a hostname, or vice-versa.

nslookup example.com

Deeper `nslookup` Queries

Beyond simple IP lookups, nslookup can query for different types of DNS records:

  • MX (Mail Exchanger): Mail server addresses.
  • NS (Name Server): Authoritative DNS servers for a domain.
  • TXT (Text): General text information, often used for verification.

Use set type=MX (or NS, TXT) before your query.

nslookup
set type=MX
google.com
exit

`dig`: The Advanced DNS Tool

While nslookup is easy, dig (Domain Information Groper) offers more detailed and flexible DNS querying capabilities.

It's preferred by network administrators for its comprehensive output and ability to query specific DNS servers.

dig example.com

Understanding `dig`'s Output

dig provides a more verbose output than nslookup, including:

  • Question Section: What you asked for.
  • Answer Section: The DNS records found.
  • Authority Section: Name servers for the domain.
  • Additional Section: Extra helpful records.

This detail is invaluable for troubleshooting.

Quick Check: Network Tools

You're troubleshooting a website that's slow to load. You suspect a bottleneck somewhere between your machine and the server.

Which command would you use to trace the path and identify potential points of delay?

Recap: Network Diagnostics

Great job! You've learned to use powerful tools for network diagnostics:

  • traceroute maps the path to a host, showing latency at each hop.
  • nslookup queries DNS for basic domain-to-IP resolution.
  • dig provides more detailed and flexible DNS query options.

These commands are essential for understanding and troubleshooting network issues!

常见问题解答

「网络诊断:`traceroute`、`nslookup`、`dig`」课时是免费的吗?

是的 — 「网络诊断:`traceroute`、`nslookup`、`dig`」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Linux Command Line Mastery 课程的其余内容,请升级到 CoddyKit PRO。 Linux Command Line Mastery 课程共包含 4 节课。

「网络诊断:`traceroute`、`nslookup`、`dig`」这节课中我会学到什么?

使用专用命令行工具进行高级网络故障排查和 DNS 查询。 你通过在浏览器中直接运行的动手代码来练习 Linux Command Line Mastery,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Linux Command Line Mastery 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Linux Command Line Mastery 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「网络诊断:`traceroute`、`nslookup`、`dig`」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Linux Command Line Mastery 课中编写并运行代码吗?

能。每节 Linux Command Line Mastery 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 网络诊断:`traceroute`、`nslookup`、`dig`
  2. 防火墙管理:`ufw`、`firewalld`、`iptables`
  3. 安全 Shell 密钥管理
  4. 使用 tcpdump 捕获并检查流量
← 返回 Linux Command Line Mastery