Why capture your own traffic?
There are plenty of sample PCAPs online, but nothing beats capturing your own traffic. When you are troubleshooting a specific issue, investigating suspicious activity, or learning how a protocol works in your own environment, you need a capture from your network.
The good news is that every major operating system has tools for this. Some are built in. Some are free downloads. All of them produce standard PCAP or PCAPNG files that you can open in Wireshark, upload to PcapHub, or analyse with any packet analysis tool.
Linux
Linux has the most options and the most flexibility.
tcpdump
tcpdump is installed on almost every Linux system. It is the go-to tool for quick command-line captures.
# Capture 100 packets on eth0
sudo tcpdump -i eth0 -c 100 -w capture.pcap
# Capture all traffic on any interface
sudo tcpdump -i any -w capture.pcap
# Capture only traffic on port 443
sudo tcpdump -i eth0 port 443 -w https_traffic.pcap
# Capture traffic to/from a specific host
sudo tcpdump -i eth0 host 192.168.1.100 -w host_traffic.pcap
# Capture with a time limit (60 seconds)
timeout 60 sudo tcpdump -i eth0 -w capture.pcap
Always use -w to write to a file. Without it, tcpdump prints packet summaries to the terminal which is useful for quick checks but loses the raw data you need for proper analysis.
tshark
tshark is Wireshark's command-line companion. It offers the same powerful dissection engine without the GUI.
# Basic capture
sudo tshark -i eth0 -w capture.pcapng
# Capture with a display filter applied during capture
sudo tshark -i eth0 -f "tcp port 80" -w http.pcapng
# Capture with a packet count limit
sudo tshark -i eth0 -c 500 -w capture.pcapng
tshark produces PCAPNG files by default, which support more features than PCAP (multiple interfaces, packet comments, better timestamps).
Wireshark (GUI)
If you have a desktop Linux environment, Wireshark gives you a visual interface:
- Open Wireshark
- Select your network interface from the list
- Click the blue shark fin button to start capturing
- Click the red square to stop
- File > Save As to save your capture
macOS
tcpdump
macOS includes tcpdump by default. The syntax is the same as Linux:
# Capture on the default interface
sudo tcpdump -i en0 -w capture.pcap
# Capture on WiFi (usually en0 on Mac)
sudo tcpdump -i en0 -c 200 -w wifi_capture.pcap
On macOS, your WiFi interface is typically en0. Use ifconfig or networksetup -listallhardwareports to find the right interface name.
Wireshark
Wireshark is available for macOS. Download it from wireshark.org, install it, and the capture process is identical to Linux.
Built-in packet capture
macOS also has a built-in diagnostic tool:
# Use the built-in packet trace
sudo tcpdump -i en0 -w ~/Desktop/capture.pcap
Windows
Wireshark
Wireshark is the most common tool on Windows. Download from wireshark.org and install it. During installation, make sure to install Npcap (the packet capture driver) when prompted.
- Open Wireshark as Administrator
- Select your network adapter (usually "Ethernet" or "Wi-Fi")
- Click Start
- Perform the activity you want to capture
- Click Stop
- Save the file
PowerShell (built-in)
Windows 10 and later include a built-in packet capture tool that requires no additional software:
# Start a capture (run as Administrator)
netsh trace start capture=yes tracefile=C:\capture.etl maxsize=200
# Stop the capture
netsh trace stop
This produces an ETL file, not a PCAP. You will need to convert it using etl2pcapng (a free Microsoft tool) or open it directly in Microsoft Network Monitor.
pktmon (Windows 10+)
A newer built-in option:
# Start capture
pktmon start --etw -f capture.etl
# Stop capture
pktmon stop
# Convert to PCAPNG
pktmon pcapng capture.etl -o capture.pcapng
pktmon can convert directly to PCAPNG, which makes it the easiest built-in Windows option.
Tips for better captures
1. Filter at capture time
Capturing everything on a busy network produces enormous files. Use capture filters to narrow down what you record:
port 53for DNS onlyhost 10.0.0.5for traffic to/from one hostnet 192.168.1.0/24for a specific subnettcp port 443for HTTPS only
2. Set a size or time limit
Unbounded captures will fill your disk. Always set a limit:
# Stop after 1000 packets
sudo tcpdump -i eth0 -c 1000 -w capture.pcap
# Stop after 100MB
sudo tcpdump -i eth0 -W 1 -C 100 -w capture.pcap
# Stop after 5 minutes
timeout 300 sudo tcpdump -i eth0 -w capture.pcap
3. Use a dedicated interface when possible
If you are capturing on a server or security appliance, use a dedicated monitoring port or SPAN/mirror port. This avoids capturing your own management traffic and gives you a cleaner view of the network.
4. Document what you captured
When you save or upload a PCAP, include context: what interface you captured on, what time period it covers, what activity was happening, and what you were investigating. Future you (or anyone you share it with) will thank you.
PCAP files can contain sensitive data including passwords, tokens, personal communications, and private network information. Review your captures before sharing them publicly. Consider filtering out sensitive traffic before uploading.
What to do with your capture
Once you have a PCAP file, you can:
- Open it in Wireshark for detailed analysis
- Upload it to PcapHub to store, tag, and share it
- Run it through Suricata for threat detection
- Share it with colleagues for collaborative troubleshooting
The hardest part of packet analysis is often just getting started. Now you have the tools. Go capture something.