TCPDump cheatsheet

General Syntax

tcpdump [options] [expression]

Packet Capturing Options

SwitchSyntaxDescription
-i anytcpdump -i anyCapture from all interfaces
-i eth0tcpdump -i eth0Capture from specific interface ( Ex Eth0)
-ctcpdump -i eth0 -c 10Capture first 10 packets and exit
-Dtcpdump -DShow available interfaces
-Atcpdump -i eth0 -APrint in ASCII
-wtcpdump -i eth0 -w tcpdump.txtTo save capture to a file
-rtcpdump -r tcpdump.txtRead and analyze saved capture file
-ntcpdump -n -I eth0Do not resolve host names
-nntcpdump -n -i eth0Stop Domain name translation and lookups (Host names or port names )
tcptcpdump -i eth0 -c 10 -w tcpdump.pcap tcpCapture TCP packets only
porttcpdump -i eth0 port 80Capture traffic from a defined port only
hosttcpdump host 192.168.1.100Capture packets from specific host
nettcpdump net 10.1.1.0/16Capture files from network subnet
srctcpdump src 10.1.1.100Capture from a specific source address
dsttcpdump dst 10.1.1.100Capture from a specific destination address
<service>tcpdump httpFilter traffic based on a port number for a service
<port>tcpdump port 80Filter traffic based on a service
port rangetcpdump portrange 21-125Filter based on port range
-Stcpdump -S httpDisplay entire packet
ipv6tcpdunp -IPV6Show only IPV6 packets
-dtcpdump -d tcpdump.pcapdisplay human readable form in standard output
-Ftcpdump -F tcpdump.pcapUse the given file as input for filter
-Itcpdump -I eth0set interface as monitor mode
-Ltcpdump -LDisplay data link types for the interface
-Ntcpdump -N tcpdump.pcapnot printing domian names
-Ktcpdump -K tcpdump.pcapDo not verify checksum
-ptcpdump -p -i eth0Not capturing in promiscuous mode

Logical Operators

OperatorSyntaxExampleDescription
ANDand, &&tcpdump -n src 192.168.1.1 and dst port 21Combine filtering options
ORor,
EXCEPTnot, !tcpdump dst 10.1.1.1 and not icmpNegation of the condition
LESS<tcpdump <32Shows packets size less than 32
GREATER>tcpdump >=32Shows packets size greater than 32

Output options

SwitchDescription
-qQuite and less verbose mode display less details
-tDo not print time stamp details in dump
-vLittle verbose output
-vvMore verbose output
-vvvMost verbose output
-xPrint data and headers in HEX format
-xxPrint data with link headers in HEX format
-XPrint output in HEX and ASCII format excluding link headers
-XXPrint output in HEX and ASCII format including link headers
-ePrint Link (Ethernet) headers
-SPrint sequence numbers in exact format

Protocols

  • Ether
  • fddi
  • icmp
  • ip
  • ip6
  • ppp
  • radio
  • rarp
  • slip
  • tcp
  • udp
  • wlan

Common Commands with Protocols for Filtering Captures

CommandDescription
src/ dsthost (host name or IP)Filter by source or destination IP address or host
ether src/ dst host (ethernet host name or IP)Ethernet host filtering by source or destination
src/ dstnet (subnet mask in CIDR)Filter by subnet
tcp/udp src/dst port ( port number)Filter TCP or UDP packets by source or destination port
tcp/udp src/dst port range ( port number range)Filter TCP or UDP packets by source or destination port range
ether/ip broadcastFilter for Ethernet or IP broadcasts
ether/ip multicastFilter for Ethernet or IP multicasts