0Pricing
Linux Networking & TCP/IP for Developers · บทเรียน

การจับแพ็กเก็ตด้วย Wireshark/tcpdump

เรียนรู้การจับและวิเคราะห์แพ็กเก็ตเครือข่ายด้วย `tcpdump` บนบรรทัดคำสั่งและ Wireshark สำหรับการวิเคราะห์ด้วยภาพ

การจับแพ็กเก็ตด้วย Wireshark/tcpdump เป็นบทเรียน Linux Networking & TCP/IP for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส 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 ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Networking & TCP/IP for Developers หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Networking & TCP/IP for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 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. การวินิจฉัย DNS ด้วย dig และ nslookup
← กลับไปที่ Linux Networking & TCP/IP for Developers