# Reading / Writing Captures to a Filetcpdump port 80 -w capture_file
# read PCAP files by using the -r switchtcpdump -r capture_file
# port 2000 of any nictcpdump -i any port 2000 –nn
# Everything on an interfacetcpdump -i eth0
# Find Traffic by IP# One of the most common queries, using host, you can see traffic that’s going to or from 1.1.1.1.tcpdump host 1.1.1.1
# Filtering by Source and/or Destinationtcpdump src 1.1.1.1
tcpdump dst 1.0.0.1
# Finding Packets by Networktcpdump net 1.2.3.0/24
# Get Packet Contents with Hex Outputtcpdump -c 1 -X icmp
# Show Traffic Related to a Specific Porttcpdump port 3389tcpdump src port 1025# Show Traffic of One Protocoltcpdump icmp
# Show only IP6 Traffictcpdump ip6
# Find Traffic Using Port Rangestcpdump portrange 21-23
# Find Traffic Based on Packet Sizetcpdump less 32tcpdump greater 64tcpdump <=128# ==================================# It’s All About the Combinations# ========= AND =========# and or &&# ========= OR =========# or or ||# ========= EXCEPT =========# not or !# From specific IP and destined for a specific Port# Let’s find all traffic from 10.5.2.3 going to any host on port 3389.tcpdump -nnvvS src 10.5.2.3 and dst port 3389# From One Network to Another# Let’s look for all traffic coming from 192.168.x.x and going to the 10.x or 172.16.x.x networks# and we’re showing hex output with no hostname resolution and one level of extra verbosity.tcpdump -nvX src net 192.168.0.0/16 and dst net 10.0.0.0/8 or 172.16.0.0/16
# Non ICMP Traffic Going to a Specific IP# This will show us all traffic going to 192.168.0.2 that is not ICMP.tcpdump dst 192.168.0.2 && src ! icmp
tcpdump dst 192.168.0.2 and src not icmp
# catch packages from(to) eth0 or eth1tcpdump -vi eth0 || eth1 -w tmp.pcap
Advanced
match MAC address & VLAN
ether host - capture packets sent from and to
ether src - capture packets sent from
ether dst - capture packets sent to
vlan - match
match protocol
Match protocols in L3 header:
ip proto - PROTO: icmp, icmp6, igmp, igrp, pim, ah, esp, vrrp, udp, or tcp
Follow are abbreviations:
icmp = proto icmp
tcp = proto tcp
udp = proto udp
Match protocols in L2 header:
ether proto - PROTO: ip, ip6, arp, rarp, atalk, aarp, decnet, sca, lat, mopdl, moprc, iso, stp, ipx, or netbeui