Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
tcpdump captures and displays network packets from the command line, using Berkeley Packet Filter expressions to select exactly the traffic an engineer needs to see.

What Is tcpdump?
tcpdump reads packets off a network interface and prints them, or writes them to a file for later analysis. It has been doing this since 1988, when it was written at the Lawrence Berkeley National Laboratory, and the packet capture library it spawned, libpcap, underpins most of the tools that followed. On any Unix-like system, it is the fastest route from “the network is behaving strangely” to actual evidence.
Its value today is partly that it is already installed. When you are on a production server at two in the morning, a single-binary tool with no graphical interface and no dependencies is exactly what you want.
Capturing everything on a busy interface produces a file nobody can use. Berkeley Packet Filter expressions solve that by selecting traffic in the kernel before it ever reaches the application, which keeps overhead low even on loaded systems.
| Expression | Selects |
|---|---|
host 10.0.4.19 | Traffic to or from one address |
net 192.168.20.0/24 | A whole subnet |
port 443 | One service port, either direction |
tcp and not port 22 | TCP, excluding your own session |
tcp[tcpflags] & tcp-syn != 0 | Connection attempts, for spotting scans |
vlan and host 10.2.0.5 | Traffic inside a tagged VLAN |
That last point catches people out: on a trunk port, filters fail silently unless the expression accounts for the VLAN tag, because the offsets of everything after it shift.
A handful of flags cover most work. -i selects the interface, and -i any captures across all of them on Linux. -n suppresses name resolution, which stops the tool generating DNS traffic of its own while you are trying to analyse DNS traffic. -w writes a pcap file and -r reads one back. -c stops after a number of packets, and -G with -W rotates files on a time interval so a long capture does not fill the disk.
For sustained capture, rotation plus a size limit is the difference between useful evidence and an outage caused by a full filesystem. Run the capture under a dedicated account with -Z, or grant the binary only the network capture capability rather than full root, because packet parsers have a long history of vulnerabilities and the parsing happens on data an attacker controls.
The normal division of labour is capture on the server with tcpdump, analysis on a workstation with Wireshark. The file format is the same, so a capture taken with -w opens directly. This avoids installing a graphical application on a production host and avoids the temptation to run a heavyweight dissector as root on live traffic.
Two details matter when handing files over. Use a sufficient snap length so packets are not truncated, which modern versions default to. And record the capture point, interface, and time zone alongside the file, because a packet capture with no context is difficult to interpret and useless as evidence.
In incident response, tcpdump answers questions no log can: what exactly did this host send, to where, and when. Capturing traffic from a suspect machine confirms beaconing intervals, reveals the destinations behind a command and control channel, and shows whether data left in volume. In testing, it verifies that traffic takes the path you believe it takes, which routinely disproves assumptions about segmentation and proxy enforcement.
It is also a diagnostic for other tools: when a scan returns nothing, a capture shows whether packets left the interface at all. Full-content capture complements Zeek and Suricata, which summarise continuously but rarely retain payloads.
Packet capture on a corporate network is lawful when done by the operator for security and network management, but it is not unconstrained. A full-content capture will contain personal data: email content, form submissions, authentication material, and browsing activity. Under UK GDPR that makes it personal data processing, requiring a lawful basis, a defined retention period, access restrictions, and inclusion in your records of processing. Interception of communications is also regulated under the Investigatory Powers Act 2016, and the operator exemption depends on the purpose.
The practical controls are straightforward: filter narrowly rather than capturing everything, prefer headers over payloads where the question allows it, store capture files encrypted with restricted access, delete them when the investigation closes, and tell employees in the acceptable use policy that monitoring takes place.
Our Investigation and Incident Response Services handle capture and analysis under documented evidence procedures when an incident needs that level of detail.
tcpdump is a lightweight command-line capture tool, ideal on servers and remote systems where no graphical interface exists. Wireshark provides deep protocol dissection, stream reassembly, and visual analysis. They share the same capture format, so the usual pattern is to capture with tcpdump and transfer the file to a workstation running Wireshark.
It needs permission to open a raw socket, which traditionally meant root. On Linux, granting the binary the network raw and admin capabilities is better practice, and the -Z option drops privileges to an unprivileged user after the capture begins. This matters because packet parsers handle attacker-controlled data and have had exploitable vulnerabilities.
No. It captures what crosses the wire, so TLS-protected payloads appear as ciphertext. The visible metadata is still useful: addresses, ports, packet sizes, timing, the server name in the TLS handshake, and certificate details. For payload visibility you need the session keys or a decrypting proxy, which raises its own privacy and governance questions.
Use rotation. The -G option starts a new file at a time interval, -C rotates by file size, and -W limits how many files are kept before the oldest is overwritten. Combine that with a tight filter expression so only relevant traffic is written, and monitor free space, since a full filesystem on a production server causes its own incident.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.