Linux command: tcpdump
See packets moving across a network
When a connection fails, it helps to know whether information reached the computer at all. Computers send network data in small pieces called packets. tcpdump can display packets visible at a chosen network interface, the point where a computer sends or receives network traffic. It can show a short summary on screen or save packets for later inspection. A capture of everything on a busy interface can grow large and bury the few packets you need.
First list the available interfaces with tcpdump -D. Then choose the one carrying the traffic you want to inspect. This example captures up to 20 packets involving one host and TCP port 443:
sudo tcpdump -i eth0 -n -c 20 'host 192.0.2.10 and tcp port 443'
Replace eth0 with an interface from the list. sudo runs the command with elevated permission when your account is allowed to do that; live packet capture may require this or a configured capture permission. -i selects the interface, -n leaves addresses and ports as numbers instead of looking up names, and -c stops after the number of matching packets. The quoted filter selects packets that involve the example address and TCP port 443. TCP is a protocol for exchanging data; port 443 is commonly used for HTTPS traffic. Quoting keeps the shell from treating the filter's punctuation as shell syntax.
Save packets for later
Use -w to write packet data to a capture file instead of printing only a summary. Use -r to read a saved capture without collecting traffic again:
sudo tcpdump -i eth0 -n -c 100 -w /tmp/trace.pcap 'tcp port 443'
tcpdump -n -r /tmp/trace.pcap
The .pcap file contains packet records. It can include application data, internal addresses, or authentication material from unencrypted protocols. Store it with appropriate permissions and remove it when it is no longer needed. Reading an existing capture usually requires access to the file, not live capture permission.
Filter expressions can use words such as host, net, port, and protocol names such as tcp or udp. Combine conditions with and, or, and not. The filter language comes from libpcap, a packet-capture library; its manual documents the full syntax. The -s option sets the snapshot length, how much of each packet to keep. A short length can omit details needed for analysis, while a larger capture uses more storage and processing. Network-card offload, where the card handles some network work itself, can also change what the capture looks like.
Understand what a capture shows
A capture shows packets visible at the selected interface and capture point. Seeing a packet there does not prove that the destination application accepted or processed it. An empty result may mean the wrong interface, a filter that is too narrow, missing permission, network-card offload behavior, or packet loss while capturing.
HTTPS protects web traffic with Transport Layer Security (TLS) encryption. Packet addresses, ports, timing, and other metadata can still be visible, but the message contents are encrypted. tcpdump will not normally show a web request body as readable text unless it is decrypted with appropriate keys and tools. Follow local rules for capturing traffic, and check the installed tcpdump and filter manuals because available options can vary.




