Capturing Packets
Use Wireshark and tcpdump.
Capturing Packets is a free Cyber Security Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cyber Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Capture Packets
Packet capture records the raw network traffic flowing across an interface. It is the ground truth of what actually happened on the wire.
Analysts use captures to investigate incidents, debug protocols, and hunt for malicious activity.
Two Core Tools
The two essential tools are Wireshark, a graphical analyzer, and tcpdump, a command-line capture tool.
- tcpdump: lightweight, perfect for servers and remote capture.
- Wireshark: rich GUI for deep analysis.
Promiscuous Mode
Normally a network card ignores frames not addressed to it. Promiscuous mode tells it to capture everything it sees.
On switched networks you still only see your own traffic unless you use a SPAN port or tap.
tcpdump Basics
tcpdump captures from an interface and prints or saves packets. The most common flags select the interface and output file.
Run it with sufficient privileges to access the interface.
sudo tcpdump -i eth0 -w capture.pcap
-i eth0 capture on eth0
-w file write raw packets to fileReading a Saved Capture
You can replay a saved capture file later, with tcpdump or Wireshark.
The -r flag reads from a file instead of a live interface.
tcpdump -r capture.pcap
wireshark capture.pcapCapture Filters (BPF)
Capturing everything is wasteful. Capture filters use the Berkeley Packet Filter syntax to record only relevant traffic.
Apply them at capture time to keep files small.
tcpdump -i eth0 'host 10.0.0.5 and port 443'
tcpdump -i eth0 'tcp port 80'
tcpdump -i eth0 'udp port 53'The pcap Format
Captures are stored as pcap or the newer pcapng files. These contain the raw bytes plus a timestamp for each packet.
The format is portable, so a capture taken with tcpdump opens perfectly in Wireshark.
Wireshark Interface
Wireshark shows three panes: the packet list, the packet details (decoded protocol layers), and the packet bytes (raw hex).
Click any packet to drill from the summary down to individual bytes.
Display Filters
Wireshark display filters differ from capture filters: they hide packets after capture without discarding them.
The syntax is richer and field-aware.
ip.addr == 10.0.0.5
http.request.method == 'POST'
dns.qry.name contains 'evil'
tcp.flags.syn == 1 and tcp.flags.ack == 0Capturing at Scale
Long captures fill disks. Use ring buffers to rotate files by size or time, keeping only recent data.
This is how sensors run continuously without exhausting storage.
tcpdump -i eth0 -w cap.pcap -C 100 -W 10
-C 100 rotate every 100 MB
-W 10 keep 10 files (ring buffer)Legal and Privacy
Packet capture can expose sensitive data and is often regulated. Capture only on networks you are authorized to monitor.
Handle captures as confidential evidence and store them securely.
Quick Check
Test your understanding of packet capture.
Recap
You learned how to capture packets.
- tcpdump captures on the command line; Wireshark analyzes graphically.
- Promiscuous mode captures all visible frames.
- Capture filters (BPF) trim data at capture; display filters hide afterward.
- Captures are stored as pcap/pcapng files.
- Use ring buffers for long runs; respect legal and privacy limits.
Next you will read and interpret protocols.
Frequently asked questions
Is the “Capturing Packets” lesson free?
Yes — the full text of “Capturing Packets” is free to read here on the web, and the Cyber Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cyber Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Capturing Packets”?
Use Wireshark and tcpdump. You practise Cyber Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cyber Security Academy?
No prior experience is required. Cyber Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Capturing Packets” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cyber Security Academy lesson?
Yes. Every Cyber Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Capturing Packets
- Reading Protocols
- Detecting Anomalies
- Extracting Artifacts