tcpdump captures and analyzes network traffic passing through a network interface in real time.

Basic usage

tcpdump -i any -p tcp port 80
  • -i any — Capture on all available interfaces
  • -p — Disable promiscuous mode (only see traffic destined for the host)
  • tcp port 80 — Filter expression: only TCP packets on port 80 (HTTP)

Common filter expressions

ExpressionMatches
host 192.168.1.1Traffic to/from a specific IP
src net 10.0.0.0/8Traffic from a subnet
tcp port 443TCP traffic on port 443
udp port 53DNS traffic
icmpPing / ICMP packets
not arpExclude ARP broadcasts

Useful flags

FlagDescription
-v, -vv, -vvvIncrease verbosity
-nDon’t resolve hostnames
-XPrint hex + ASCII dump of packet payload
-w file.pcapWrite raw packets to a file
-r file.pcapRead packets from a saved file
  • netstat — show active connections and port statistics