Insights

tcpdump on Kali Linux: capture and read network traffic

5 min read

tcpdump on Kali Linux packet capture title card

tcpdump on Kali Linux: capture and read network traffic

tcpdump on Kali Linux is a command-line packet capture tool. It listens on a network interface, filters the traffic you care about, and prints each matching packet as it arrives. Testers use it to see exactly what crosses a wire during a check. Defenders use it to troubleshoot a fault, confirm what is talking to what, and prove that sensitive data is moving in the clear.

This post covers what tcpdump is, when to reach for it, how to install it on Kali, the legal limits that apply, a worked example against a lab VM you own, and the defences that reduce the risk it demonstrates.

tcpdump on Kali Linux: what it is and when to use it

tcpdump is one of the oldest packet analysers still in everyday use. The project describes it as a tool that dumps the traffic on a network, examines the headers of packets on an interface, and filters packets that match an expression. It understands IPv4, IPv6, ICMP, TCP, UDP, ARP and a long list of application protocols.

The difference from a GUI analyser matters. tcpdump is scriptable, lightweight, and happy to run over SSH on a headless box with no desktop. You can start a capture, save it to a file, and open that file later in Wireshark or tshark. That pairing is common: capture with tcpdump on a remote host, analyse in a GUI somewhere comfortable.

When a tester reaches for tcpdump, the goal is usually to confirm what a service sends without encryption, or to check whether a host leaks more than it should. When a defender reaches for it, the goal is quieter: answer a specific question about a link, a retransmission, or an unexpected flow, then stop.

Installing tcpdump on Kali Linux

Kali ships tcpdump in the base install, so it is often already present. Check first:

tcpdump --version

If it is missing, install it from Kali’s repositories:

sudo apt update
sudo apt install tcpdump

That is the standard Kali method and the same command the Kali tools page documents. tcpdump captures with libpcap and, on Kali, dropping to a regular user after opening the interface is the normal behaviour; the man page covers the privilege handling in detail.

The full option reference is in the official tcpdump man page. The filter syntax is documented separately in the pcap-filter manual. Debian and Ubuntu carry the same tool under the tcpdump package, documented in the Debian tcpdump manual page.

Keep Kali current with sudo apt update && sudo apt full-upgrade so tcpdump and libpcap stay patched.

Ethical and lawful use

Only capture traffic on a network you own or have written permission to test. In the UK, unauthorised interception or access to communications can engage the Computer Misuse Act 1990 and the Investigatory Powers Act 2016. Running tcpdump against someone else’s network is not a harmless look; it is intercepting their data.

A capture can contain passwords, tokens, personal data and message content. Treat every pcap file as sensitive. Store it encrypted, share it only with the client who owns the network, and delete it when the engagement ends. Agree the scope and the time window in writing before you start.

Worked example on a lab target you own

Lab target: a local VM on an isolated host-only network, such as the setup in our guide to creating a pentesting environment with Parrot OS and Kali Linux on VirtualBox. Nothing below touches a real system.

Start by listing the interfaces so you capture on the right one:

tcpdump -D

Capture ten packets on the lab interface, with no name lookups so the output is fast and readable:

sudo tcpdump -i eth0 -nn -c 10

What this does: -i eth0 selects the interface, -nn turns off hostname and port-name resolution, and -c 10 stops after ten packets. The output shows a timestamp, the source and destination, the protocol and the TCP flags. The flags are the quick read on a conversation: [S] is a connection opening, [S.] is the reply, [P.] is data, [F.] is a close and [R] is a reset.

To see DNS queries only, filter by port:

sudo tcpdump -i eth0 -nn port 53

To save a capture for later analysis, write it to a file and open it in Wireshark:

sudo tcpdump -i eth0 -nn -w lab-capture.pcap

The -w flag writes raw packets to lab-capture.pcap. Because the file holds whatever crossed that interface, keep it on the lab host and delete it afterwards.

Once the capture is saved, the useful follow-up is to read it from the defender’s side. Open it in Wireshark to see the same packets with decoded layers, or list the commands in our round-up of the most used Linux commands every IT professional should use. A capture on a small device, such as a Raspberry Pi on a switch port, is described in our Raspberry Pi projects for ethical hackers post.

Defences and detections

tcpdump succeeds when traffic crosses the wire in a form that reveals too much. Reduce that, and the tool has less to show.

  • Encrypt in transit. Use TLS for web and mail, SSH for remote shells, and HTTPS for anything else that carries a login. An encrypted capture shows who talked to whom, not what they said.
  • Segment the network. Keep sensitive systems on separate VLANs so a single capture point does not see everything. Limit who can run packet capture on managed hosts.
  • Prefer certificate pinning and HSTS. These reduce the chance a client accepts an intercepted connection without warning.
  • Restrict capture capability. On Linux, only grant CAP_NET_RAW or the tcpdump capability to accounts that need it. A normal user should not be able to sniff the LAN.
  • Alert on unexpected capture. Log and monitor for new interfaces in promiscuous mode or unusual pcap files, and treat unexpected capture on a server as an incident signal.

tcpdump is a scalpel, not a sledgehammer. It shows you exactly what left the building in the clear, and that evidence is the strongest argument for encrypting it.

Sources