0Pricing
Linux Networking & TCP/IP for Developers · レッスン

Wireshark・tcpdumpによるパケットキャプチャ

コマンドラインでは`tcpdump`、グラフィカルな分析ではWiresharkを使って、ネットワークパケットをキャプチャ・分析する方法を学びます。

「Wireshark・tcpdumpによるパケットキャプチャ」はCoddyKit上の無料Linux Networking & TCP/IP for Developersレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはLinux Networking & TCP/IP for Developers学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Linux Networking & TCP/IP for Developersコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What is Packet Capture?

Packet capture is like taking a snapshot of all the network data flowing in and out of your device. It's a powerful technique for understanding network behavior and troubleshooting issues.

You can see the raw "packets" of information, including their source, destination, and the data they carry. This helps diagnose slow connections, find security problems, or debug network applications.

Introducing `tcpdump`

tcpdump is a command-line utility for capturing and analyzing network traffic. It's pre-installed on most Linux systems, making it a go-to tool for quick network inspections.

It works by "sniffing" packets directly from your network interface. You can view them in real-time or save them for later analysis.

Basic Capture with `tcpdump`

Let's start with the most basic usage: capturing all traffic on a specific network interface. You often need sudo privileges to run tcpdump.

The -i flag specifies the interface (e.g., eth0 or wlan0). If you omit -i, tcpdump tries to pick one automatically.

sudo tcpdump -i eth0

Filtering by Host

Capturing all traffic can be overwhelming. You'll often want to filter for specific connections. The host keyword lets you capture traffic to or from a particular IP address or hostname.

sudo tcpdump -i eth0 host 192.168.1.1

Filtering by Port

Another common filter is by port. This is useful for seeing traffic related to specific services, like web (port 80/443), SSH (port 22), or DNS (port 53).

sudo tcpdump -i eth0 port 80

Combining Filters

You can combine filters using logical operators like and, or, and not. This allows for very precise targeting of the traffic you want to see.

For example, to see HTTP traffic to a specific host, you'd combine host and port.

sudo tcpdump -i eth0 host 192.168.1.1 and port 80

Saving to a File (`.pcap`)

For deeper analysis, it's best to save the captured packets to a file. The -w flag writes the raw packet data to a file with a .pcap extension. This file can then be opened by other tools.

The -c flag limits the number of packets to capture.

sudo tcpdump -i eth0 -c 100 -w my_capture.pcap

Wireshark: The GUI Analyzer

While tcpdump is excellent for command-line capture, Wireshark is the industry-standard graphical tool for deep packet inspection. It provides a user-friendly interface to visualize and analyze captured network data.

Wireshark can capture live traffic or open .pcap files created by tcpdump or other tools.

Importing `tcpdump` Files

A common workflow is to capture packets using tcpdump on a remote server (where a GUI might not be available) and then transfer the .pcap file to your local machine for analysis with Wireshark.

In Wireshark, you simply go to File > Open and select your .pcap file. Wireshark will then display all the captured packets in a structured way.

`tcpdump` Filter Challenge

You need to capture traffic on the eth0 interface that is going to or coming from the IP address 10.0.0.5, but ONLY on port 22 (SSH). Which tcpdump command would achieve this?

Lesson Recap

In this lesson, we explored the powerful world of packet capture. We learned how to use tcpdump to capture and filter network traffic directly from the command line.

  • Basic capture with -i
  • Filtering by host and port
  • Combining filters with and, or, not
  • Saving captures to a .pcap file with -w

We also introduced Wireshark as a graphical tool for in-depth analysis of these captured files. Mastering these tools is crucial for any network troubleshooter!

よくある質問

「Wireshark・tcpdumpによるパケットキャプチャ」レッスンは無料ですか?

はい。「Wireshark・tcpdumpによるパケットキャプチャ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Linux Networking & TCP/IP for Developersコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Linux Networking & TCP/IP for Developersコースには全4レッスンが含まれています。

「Wireshark・tcpdumpによるパケットキャプチャ」で何を学びますか?

コマンドラインでは`tcpdump`、グラフィカルな分析ではWiresharkを使って、ネットワークパケットをキャプチャ・分析する方法を学びます。 ブラウザで直接実行するハンズオンコードでLinux Networking & TCP/IP for Developersを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Linux Networking & TCP/IP for Developersを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのLinux Networking & TCP/IP for Developersは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「Wireshark・tcpdumpによるパケットキャプチャ」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このLinux Networking & TCP/IP for Developersレッスンでコードを書いて実行できますか?

はい。すべてのLinux Networking & TCP/IP for Developersレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Wireshark・tcpdumpによるパケットキャプチャ
  2. ネットワークパフォーマンスツール
  3. Linuxファイアウォール(Netfilter/iptables)
  4. digとnslookupによるDNS診断
← Linux Networking & TCP/IP for Developersに戻る