Pcornel
Linux · Network Troubleshooting

Packet Capture

Cheat sheet · https://pcornel.dk/topic.php?topic=2795

Back to the Topic

Answer

Packet capture on Linux records the packets an interface sends and receives, usually with tcpdump, so you can see exactly what left, what arrived and when.

Remember

Capture on the interface the traffic really uses (ip route get), with a filter to keep it small, and write to a file for Wireshark. Offloading makes outgoing packets look too large or with bad checksums in the capture; that is not an error on the wire. -i any loses Ethernet headers.

First checks

  • tcpdump -D — interfaces available for capture.
  • tcpdump -ni <if> host <ip> and port <port> — live view without name lookups.
  • tcpdump -ni <if> -s 0 -w /tmp/cap.pcap host <ip> — full packets to a file.
  • tcpdump -nr /tmp/cap.pcap — read a file back.
  • ethtool -k <if> — offload settings that affect what the capture shows.
  • ip route get <dst> — which interface to capture on.

Commands

tcpdump -ni <iface> <filter>
Capture packets using BPF filters.
tcpdump -ni {{interface}} {{filter}}
Captures packets on an interface without name resolution.
tcpdump -ni <iface> icmp6
Capture ICMPv6 including ND and Packet Too Big.

Verify in this order

right interface chosen → filter matches the flow → full packets written → problem reproduced during capture → packets in both directions examined → conclusion tied to timestamps

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2795

Confirmation

Confirm action

Continue?