Lesson 2 of 9 · 24m
Production Capture Methodology
tcpdump, dumpcap, ring buffers, snap lengths, privileges, and clock discipline — capturing enough evidence without creating the next incident.
The first rule of production capture is that the capture itself is production risk. Disk fills, CPU spikes, dropped packets inside the capture, and sensitive payloads are all operator-caused failures. A senior capture is narrow, bounded, timestamped, and documented before anyone presses Enter.
Use the least privileged tool that can do the job
tcpdump is everywhere and ideal for quick host captures. dumpcap is better for long-running captures because it writes pcapng with interface and statistics metadata and can run with tighter privileges.
sudo tcpdump -ni eth0 -s 256 -w /var/tmp/api-incident.pcap 'host 203.0.113.25 and tcp port 443'
sudo dumpcap -i eth0 -s 256 -w /var/tmp/api-incident.pcapng -f 'host 203.0.113.25 and tcp port 443'The -s 256 snap length keeps only the first 256 bytes of each packet. That is usually enough for Ethernet, IP, TCP, TLS handshake metadata, DNS, and HTTP headers, while cutting disk usage and reducing payload exposure. Use full packets only when the question truly depends on payloads.
Capture filters are a safety mechanism
BPF capture filters run before traffic reaches user space. Display filters do not. If you need only one service flow, filtering at capture time can reduce volume by orders of magnitude.
host 203.0.113.25 and tcp port 443
tcp port 53 or udp port 53
vlan 100 and net 10.20.30.0/24
not host 10.0.0.5Test the expression before the incident window. BPF syntax errors are unforgiving, and a filter that is technically valid but topologically wrong will collect a perfect capture of the wrong packets.
Long-running captures need boundaries
Never let an incident capture grow until the disk screams. Use ring buffers or rotation.
sudo dumpcap -i eth0 -s 256 -w /var/tmp/edge.pcapng -f 'tcp port 443' -b filesize:102400 -b files:20This keeps twenty files of roughly 100 MiB each. The oldest files rotate out. Choose size and count from the expected rate, not from habit; when the rate is unknown, take a short counted sample first.
Clock discipline is evidence discipline
Packets are compared across machines by timestamp. Check clock synchronization before drawing conclusions about one-way delay.
timedatectl
date -uStore filenames in UTC, note the machine's clock offset if known, and prefer capturing simultaneously at both ends. A 20 ms offset will not matter for retransmission analysis; a two-second offset will corrupt a latency story.
Know whether the capture itself dropped traffic
At shutdown, tcpdump reports packets captured and dropped by kernel or interface. Dumpcap stores statistics in pcapng. If the capture dropped packets, you cannot use absence as proof. Your evidence now contains holes of unknown size.
Field notes
- Never write captures to the same disk that a failing database depends on unless you have measured headroom.
- Use
/var/tmpor a dedicated capture directory with explicit free-space checks. - Treat packet payloads as sensitive data even when TLS is present; DNS, headers, and connection metadata still disclose user behavior.
- Start small: 30 seconds during a reproduced failure beats six hours of unannotated noise.
Was this lesson helpful?