TCPDump Quick Reference
Published: 2017-07-13
Intro
TCPDump is a tool for sniffing packets on a network. This is not a comprehensive tutorial, only a quick reference source. Consult the man pages and/or documentation for indepth explanation of commands.
Capturing Traffic
All Traffic for an interface-i <interface-name> specifies an interface.
cmd
sudo tcpdump -i eth1cmd
sudo tcpdump -i eth1 src 172.16.20.220cmd
sudo tcpdump -i eth1 dst 8.8.8.8cmd
sudo tcpdump -i eth1 arpcmd
sudo tcpdump -i eth1 icmp and dst 9.9.9.9cmd
sudo tcpdump -i eth1 port 67 or port 68Capture TCP and UDP
cmd
sudo tcpdump -i eth1 port 53Capture UDP only
cmd
sudo tcpdump -i eth1 udp port 53cmd
sudo tcpdump -i eth1 port 161 or port 162Ethernet
Host addresscmd
sudo tcpdump ether host aa:bb:cc:11:22:33File Output
PCAP File-w <path-to-file>.pcap specifies pcap file location.
cmd
sudo tcpdump -i eth1 -w /tmp/capture.pcapLimit Capture
Capture number of packetscmd
sudo tcpdump -i eth1 icmp -c 4cmd
sudo tcpdump -i eth1 icmp -C 10 -w /tmp/capture.pcap