Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Packet Capture

Direct 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.

When to use this

Use it when show commands and logs disagree with what the application reports, and you need proof of what was on the wire.

First 30 seconds

1. ip route get <dst> — capture on that interface.

2. Start tcpdump -ni <if> -w /tmp/cap.pcap host <ip> and port <port>.

3. Reproduce the problem, note the time, stop with Ctrl+C.

4. Requests leave, no replies arrive → beyond this host.

5. Nothing leaves → the host never sent it: routing, firewall or the application.

Operational verification

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

Evidence · next step

For Network Troubleshooting → Packet Capture, continue with the first unproven Topic check: Choose the capture point deliberately: namespace/interface/any, ingress/egress if supported, host pairs and protocol/port filter. If that boundary is healthy, advance to the adjacent check: Record exact time, interface counters and offload state; use sufficient snap length and avoid overly narrow filters during initial localization. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commandtcpdump -ni <iface> icmp6
Scope / prerequisiteUse it when show commands and logs disagree with what the application reports, and you need proof of what was on the wi…
Troubleshoot · 1Reference · 2
What next?3 suggested next steps
Catalog command links3
Evidence1
On this pageJump to a specific section
Linux command reference

Primary Commands

Configuration and operational commands for this Topic.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

original traffic generation → kernel/socket → local routing/firewall → capture hook/interface → external path → remote endpoint → return traffic → local capture → socket/application consumption

Healthy evidence: capture shows the expected request/response progression at the intended observation point and aligns with socket/application timing and adjacent path evidence.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Choose the capture point deliberately: namespace/interface/any, ingress/egress if supported, host pairs and protocol/port filter.

  • Record exact time, interface counters and offload state; use sufficient snap length and avoid overly narrow filters during initial localization.
  • Correlate SYN/SYN-ACK/ACK, retransmissions, resets, ICMP errors, DNS responses or relevant protocol events with socket/application timing.
  • Capture the opposite side or next boundary when needed, then repeat the original workload after the minimal change to show recovery.

Verification chain. original traffic generation → kernel/socket → local routing/firewall → capture hook/interface → external path → remote endpoint → return traffic → local capture → socket/application consumption

Step 3 Commands Verify boundary
tcpdump -ni eth0 -w cap.pcap host 10.0.0.5 and port 443
tcpdump -nn -r cap.pcap | head
tshark -r cap.pcap -Y tls.handshake
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: packets disappear between boundaries, retransmit/reset/ICMP patterns contradict expected flow, capture scope is ambiguous, or offload/filter artifacts are misread as network faults.

Packet capture shows only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.

Step 5 Common mistakes Narrow the fault
  • Capturing without filters and filling the disk.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

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.

Key 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.
ReferenceWhat it is1 section · depth on demand

Core model

A capture is evidence at one observation point. Pin interface/namespace, direction, snap length, offload context, filter and clock; reproduce the original traffic; then interpret sequence/flags/ICMP/DNS or protocol exchange together with routing, firewall, socket and remote-side evidence. Missing packets show absence only at the capture point when coverage is known.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Packet capture shows only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.

tcpdump Command remains the existing command leaf; Networking/Firewall/application Topics own interpretation and remediation at their respective boundaries.

In depth

Packet capture with tcpdump

When logs and connection tests don't explain a problem, a packet capture shows what actually happens on the wire. The tcpdump(1) manual page documents the options used most:

  • -i selects the interface. any captures on all of them, but not in promiscuous mode.
  • -n keeps addresses and ports numeric, and -e shows link-layer headers.
  • -c stops after a number of packets.
  • -w writes raw packets to a file, and -r reads one.
  • -s sets the snapshot length (default 262144 bytes).
  • -C, -G and -W rotate capture files, and -Z drops privileges after opening the device.
  • A non-zero "packets dropped by kernel" count means the capture buffer overflowed, which -B can enlarge.

The pcap-filter(7) manual page defines the filter language:

  • host, net, port and portrange, with src/dst qualifiers.
  • Protocols such as tcp, udp and icmp.
  • and, or and not, with parentheses.
  • TCP flags with tcp[tcpflags], and VLANs with vlan <id>.

Filters for common questions

QuestionFilter
Traffic to or from one hosthost 10.30.0.40
One servicetcp port 5432
Only connection attempts'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack == 0'
Resets'tcp[tcpflags] & tcp-rst != 0'
DNSudp port 53 or tcp port 53
Exclude your own SSH sessionnot port 22
A VLAN on a trunkvlan 110 and host 10.110.0.64

Capturing safely on production

PracticeReason
Always use a filterLess load; fewer drops; less sensitive data
-w to a file, analyse elsewhereWireshark gives better analysis
Rotation with -C/-W, or a packet countNo full disks
Capture on both ends when possibleShows whether packets leave and whether they arrive
Treat capture files as sensitiveThey contain payloads, sometimes credentials
host$ sudo tcpdump -ni eth0 -c 6 'host 10.30.0.40 and tcp port 5432'
16:12:01.100 IP 10.110.0.64.51822 > 10.30.0.40.5432: Flags [S], seq 3127, win 64240, length 0
16:12:02.131 IP 10.110.0.64.51822 > 10.30.0.40.5432: Flags [S], seq 3127, win 64240, length 0
16:12:04.179 IP 10.110.0.64.51822 > 10.30.0.40.5432: Flags [S], seq 3127, win 64240, length 0
db1$ sudo tcpdump -ni eth0 -c 3 'tcp port 5432 and host 10.110.0.64'
16:12:01.101 IP 10.110.0.64.51822 > 10.30.0.40.5432: Flags [S], seq 3127, win 64240, length 0
host$ sudo tcpdump -ni any -w /tmp/pg-%H%M.pcap -G 300 -W 12 -Z tcpdump 'tcp port 5432'
host$ tcpdump -nr /tmp/pg-1615.pcap 'tcp[tcpflags] & tcp-rst != 0' | head

Reading the two captures

The client retransmits its SYN, and gets no answer. On db1, the SYN arrives, but there is no SYN-ACK. The packet reaches the server, which doesn't respond. So the cause is on db1: a host firewall dropping the packet, or nothing listening on that address with RST blocked. That's a conclusion only a capture on both ends can give.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Packet Capture is part of Network Troubleshooting → Packet Capture. Packet Capture uses Linux capture facilities such as tcpdump/libpcap to observe packets at a selected interface/namespace and time so troubleshooting can distinguish what the host sent, received, retransmitted, rejected or never observed.

Topic-specific state model. Packet Capture uses Linux capture facilities such as tcpdump/libpcap to observe packets at a selected interface/namespace and time so troubleshooting can distinguish what the host sent, received, retransmitted, rejected or never observed.

Interpretation rule. - Packet absent in one capture ≠ packet absent everywhere; wrong interface/namespace/filter or offload can hide it.

  • Packet visible on egress ≠ remote received it; path devices can drop later.
  • Response visible on wire ≠ application consumed it; local firewall/socket/process can fail after capture point.
  • Checksum errors in local capture ≠ wire corruption when checksum offload defers calculation to NIC hardware.

Quick reference

Packet capture with tcpdump:

tcpdump -ni eth0 host 10.20.30.40 and port 443
tcpdump -ni any -w /tmp/cap.pcap -C 100 -W 5 'port 53 or port 853'   # ring buffer
tcpdump -nni eth0 'tcp[tcpflags] & (tcp-syn|tcp-rst) != 0'
tcpdump -ni eth0 -e vlan                 # show VLAN tags/MACs
tcpdump -r /tmp/cap.pcap -nn | head
tshark -r cap.pcap -Y 'tcp.analysis.retransmission'

Capture on both ends to see where packets disappear. -i any loses link-layer headers (use a specific interface for VLAN/MAC analysis). Offloads (GRO/TSO) make captured packets look larger than the MTU — normal.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Packet capture shows only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Packet Capture owns Linux packet-observation methodology. tcpdump Command remains the existing command leaf; Networking/Firewall/application Topics own interpretation and remediation at their respective boundaries.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Network Troubleshooting → Packet Capture. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.kernel.org/networking/index.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
packet capture linuxtcpdump troubleshootingpcap linuxcapture packets linux
Embedded reference data

Quick lookup tables

Packet Capture operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Packet Capture.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statePacket Capture uses Linux capture facilities such as tcpdump/libpcap to observe packets at a selected interface/namespace and time so troubleshooting can distinguish what the host sent, received, retransmitted, rejected or never observed.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin exact host/namespace + original name or endpoint → capture link/address/route/resolver state → reproduce original failure → localize first failed resolver/network boundary → collect bounded packet/socket or DNS evidence → change one demonstrated cause → read back effective state → repeat original application transaction and an adjacent regression check.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainoriginal traffic generation → kernel/socket → local routing/firewall → capture hook/interface → external path → remote endpoint → return traffic → local capture → socket/application consumptionTrace requested/configured state through effective state to the observed workload result.
Failure boundaryPacket capture proves only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux DNS/network evidence can establish this proof path: original traffic generation → kernel/socket → local routing/firewall → capture hook/interface → external path → remote endpoint → return traffic → local capture → socket/application consumptionUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured host/network namespace, resolver path or DNS view, interface/source, destination/protocol/port, capture point, time or workload scope. Packet capture proves only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven DNS/network boundary: preserve the original source and failure conditions, capture the adjacent resolver/socket/packet state, change only the demonstrated cause, then repeat the original application lookup or transaction and adjacent regression checks.Continue to the next unresolved boundary while preserving the original test condition.

Packet Capture · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryPacket Capture
Topic pathNetwork Troubleshooting → Packet Capture
Runtime statePacket Capture uses Linux capture facilities such as tcpdump/libpcap to observe packets at a selected interface/namespace and time so troubleshooting can distinguish what the host sent, received, retransmitted, rejected or never observed.
Fast checks- Choose the capture point deliberately: namespace/interface/any, ingress/egress if supported, host pairs and protocol/port filter. - Record exact time, interface counters and offload state; use sufficient snap length and avoid overly narrow filters during initial localization. - Correlate SYN/SYN-ACK/ACK, retransmissions, resets, ICMP errors, DNS responses or relevant protocol events with socket/application timing. - Capture the opposite side or next boundary when needed, then repeat the original workload after the minimal change to prove recovery.
Verification chainoriginal traffic generation → kernel/socket → local routing/firewall → capture hook/interface → external path → remote endpoint → return traffic → local capture → socket/application consumption Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryPacket capture proves only what was observed at the chosen hook/interface/namespace/time/filter; end-to-end conclusions require correlation with adjacent capture points, socket state and the original application result.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?