Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · capture & filtering

tcpdump

reading the wire itself

tcpdump attaches to an interface and prints every packet that matches a filter — timestamp, addresses, ports and the protocol's own fields. When two machines disagree about what was sent, the capture is the only account neither of them wrote.

Logs record what a program believed happened. A capture records what was actually on the wire.

Reads
Raw packets
via libpcap
Needs root
Yes
or CAP_NET_RAW
Filter language
BPF
host, port, tcp, and, or, not
Save for later
-w file.pcap
open it in Wireshark

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

root@netflow — bashtcpdump
# tcpdump -ni eth0 -c 3 'tcp port 443'
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
114:02:11.482913 IP 192.168.1.42.51844 > 192.0.2.10.443: Flags [S], seq 2812344571, win 64240, options [mss 1460,sackOK,nop,wscale 7], length 0
214:02:11.494760 IP 192.0.2.10.443 > 192.168.1.42.51844: Flags [S.], seq 1094023318, ack 2812344572, win 65160, options [mss 1460,sackOK,nop,wscale 7], length 0
314:02:11.494811 IP 192.168.1.42.51844 > 192.0.2.10.443: Flags [.], ack 1, win 502, length 0
43 packets captured
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
Flags [S] is the SYN

The client, from ephemeral port 51844, asks to open a connection to port 443 and announces its initial sequence number.

2
Flags [S.] is the SYN-ACK

The dot is the ACK bit. The server acknowledges the client's sequence number plus one and offers its own. About 12 ms after the SYN — that gap is the round-trip time.

3
Flags [.] completes the handshake

A bare ACK from the client. tcpdump now prints relative numbers, so "ack 1" means one past the server's initial sequence.

4
-c 3 stopped the capture

Without a count it runs until interrupted. "length 0" on all three confirms no application data has moved yet — that begins with the next packet.

Switches

A switch changes how the command behaves. These are the ones used day to day; man tcpdump lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-i IFACE
Capture on this interface. "any" captures on all of them.
-n
Numeric: do not turn addresses into names. -nn leaves ports as numbers too.
-c NUM
Stop after capturing NUM packets.
-w FILE
Write the raw packets to a file, to open later in Wireshark.
-r FILE
Read packets back from a saved capture file.
-v
Verbose: decode more of each packet. -vv and -vvv go further.
-e
Show the link-layer header: source and destination MAC addresses.
-A
Print each packet’s payload as text.
-X
Print each packet’s payload in hex and text side by side.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

tcpdump -ni any port 53

DNS on every interface — the quickest way to see which names a host is asking for.

tcpdump -ni eth0 -w capture.pcap host 192.0.2.10

Writes full packets for one peer to a file, to open in Wireshark later.

tcpdump -ni eth0 'tcp[tcpflags] & (tcp-syn|tcp-rst) != 0'

Only SYN and RST packets: every connection attempt and every refusal.

tcpdump -ni eth0 -e arp

ARP requests and replies with the Ethernet headers shown — who is claiming which address.

In cybersecurity

A capture shows everything that is not encrypted, to whoever is able to run one. It is the defender's best evidence and the reason plaintext protocols are a liability.

Plaintext is readable

Telnet, FTP and plain HTTP put credentials on the wire as text. One capture with -A is all it takes to prove it.

Capture files are sensitive

A pcap holds whatever crossed the link — session cookies, internal names, sometimes passwords. Store and share it accordingly.

Who may capture

CAP_NET_RAW is close to full visibility of the host's traffic. Grant it deliberately, not by adding users to a group.

TLS limits the view

Encrypted traffic shows addresses, ports, timing and the server name in the handshake — not the content.

Scans are obvious here

A burst of SYNs to many ports from one source, answered by RSTs, is a port scan as it looks on the wire.

Capture where it matters

A host sees only its own traffic on a switched network. Seeing more needs a mirror port or a tap.

Protocols it shows

TCPUDPIPv4EthernetARPTLS

Read alongside