0Pricing
Linux Command Line Mastery · 课时

使用 tcpdump 捕获并检查流量

通过使用 tcpdump 捕获实时数据包并应用筛选器,完善网络与安全工具集,以诊断连接和安全问题。

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

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

Seeing the Wire

Diagnostics like ping and dig tell you whether something works, but sometimes you need to see the actual packets. tcpdump captures network traffic in real time.

Listing Interfaces

First find which interface to listen on with -D. Common names are eth0, wlan0, or en0.

sudo tcpdump -D

A Basic Capture

-i selects the interface. Capturing requires root because it reads raw packets.

sudo tcpdump -i eth0

Limiting the Capture

-c stops after N packets so the terminal does not flood, useful for a quick look.

sudo tcpdump -i eth0 -c 10

Filtering by Host

Capture filters narrow the noise. host limits to traffic to/from one address.

sudo tcpdump -i eth0 host 8.8.8.8

Filtering by Port

Use port to focus on a service. Here we watch only HTTPS traffic.

sudo tcpdump -i eth0 port 443

Combining Filters

Filters combine with and, or, not for precise targeting.

sudo tcpdump -i eth0 tcp and port 22 and not host 10.0.0.1

Readable Output Flags

-n skips DNS lookups (faster, shows IPs), and -v adds detail. -A prints packet payloads as ASCII.

sudo tcpdump -i eth0 -nv port 80

Saving to a File

-w writes raw packets to a .pcap file you can analyze later, e.g. in Wireshark.

sudo tcpdump -i eth0 -w capture.pcap

Reading a Capture

-r replays a saved capture, and you can still apply filters while reading.

tcpdump -r capture.pcap port 443

Security Use Cases

tcpdump helps spot unexpected outbound connections, confirm a firewall rule is blocking traffic, or verify that sensitive data is encrypted on the wire.

Quick Check

What does the -w option do in tcpdump?

Recap

You can now inspect live traffic:

  • -i picks the interface, -c limits count
  • Filters: host, port, combined with and/or/not
  • -n/-v/-A shape output
  • -w saves and -r reads .pcap files

tcpdump turns invisible packets into a debuggable stream.

常见问题解答

「使用 tcpdump 捕获并检查流量」课时是免费的吗?

是的 — 「使用 tcpdump 捕获并检查流量」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Linux Command Line Mastery 课程的其余内容,请升级到 CoddyKit PRO。 Linux Command Line Mastery 课程共包含 4 节课。

「使用 tcpdump 捕获并检查流量」这节课中我会学到什么?

通过使用 tcpdump 捕获实时数据包并应用筛选器,完善网络与安全工具集,以诊断连接和安全问题。 你通过在浏览器中直接运行的动手代码来练习 Linux Command Line Mastery,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

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

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

「使用 tcpdump 捕获并检查流量」课时需要多长时间?

大多数 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