Dilip Antony Joseph, Vern Paxson, Sukun Kim: Tcpdump (Options) (Filter Expression)
Dilip Antony Joseph, Vern Paxson, Sukun Kim: Tcpdump (Options) (Filter Expression)
1
Demo 2 Demo 2 (contd.)
1. Capture only udp packets 1. Capture only UDP packets with destination
port 53 (DNS requests)
• tcpdump “udp”
• tcpdump “udp dst port 53”
2. Capture only tcp packets 2. Capture only UDP packets with source port 53
• tcpdump “tcp” (DNS replies)
• tcpdump “udp src port 53”
3. Capture only UDP packets with source or
destination port 53 (DNS requests and replies)
• tcpdump “udp port 53”
2
Assignment Requirements Security/Privacy Issues
• -w <dump_file_name> -s 0 options must • tcpdump allows you to monitor other people’s
traffic
be used for the traces submitted as part of • WARNING: Do NOT use tcpdump to violate
the assignments privacy or security
• Use filtering to restrict packet analysis to only
the traffic associated with your echo_client and
• Appropriately name each dump file you echo_server. The following is one way to ensure
submit and briefly describe what each that you see only traffic associated with your
dump file contains/illustrates in the client:
– tcpdump –s 0 –w all_pkts.trace
README file associated with the – tcpdump –s 0 –r all_pkts.trace “ –w my_pkts.trace
assignment submission “port 12345”
– where 12345 is the ephemeral port which your
echo_client uses to talk to the echo_server.
Cheat Sheet – Writing Filters (1) Cheat Sheet – Writing Filters (2)
• Specifying the hosts we are interested in • Specifying ICMP packets
– “dst host <name/IP>” – “icmp”
– “src host <name/IP>”
– “host <name/IP>” (either source or destination is
• Specifying UDP packets
name/IP) – “udp”
• Specifying the ports we are interested in • Specifying TCP packets
– “dst port <number>” – “tcp”
– “src port <number>”
– “port <number>”
– Makes sense only for TCP and UDP packets
3
Appendix: IPsumdump on EECS
Cheat Sheet – Writing Filters (2)
instructional accounts
• Download and untar the latest IPsumdump source distribution from
• Combining filters http://www.cs.ucla.edu/~kohler/ipsumdump/
– and (&&)
• Set the following PATH and LD_LIBRARY_PATH environment
– or (||) variables by using setenv or export (bash shell)
– not (!) – setenv PATH /usr/ccs/bin:$PATH
– setenv LD_LIBRARY_PATH /usr/sww/lib
• Example:
• Run ./configure followed by make. The executable is created in the
– All tcp packets which are not from or to host src/ subdirectory
quasar.cs.berkeley.edu
• Use ipsumdump to analyze trace files generated by tcpdump (using
tcpdump “tcp and ! host quasar.cs.berkeley.edu” –w option).
– Lots of examples in the EXAMPLES section of the – For example: ipsumdump -r tracefile -s --payload prints the source and
payload of the packets in tracefile in an easy-to-read format
man page