Tcpdump

From Hackepedia
Revision as of 13:01, 8 December 2005 by Franks (talk | contribs)
Jump to navigationJump to search

tcpdump is a OSI layer 2+ sniffer. It'll sniff Ethernet, PPP, and SLIP. The name is misleading since TCP is on OSI layer 4. tcpdump uses a library called libpcap which is a library that implements datalink (layer 2) capturing facilities. In BSD libpcap uses the bpf interface to access the data link.

In UBOs, one can only use tcpdump as root. This is a new implementation to ensure that privilege seperation works. If you're looking for a GUI sniffer, you might want to try Ethereal instead.

This example shows all traffic from host 192.168.1.6 on the rl0 interface.

# tcpdump -i rl0 host 192.168.1.6

Here is an example of seeing ICMP packets of type 8 (ECHO REQUEST or ping packets):

# tcpdump -v -n -i pppoe0 icmp[0] == 8 
tcpdump: listening on pppoe0, link-type PPP_ETHER
13:35:51.690236 85.75.39.172 > 206.248.137.44: icmp: echo request (id:8e2c seq:0) (ttl 255, id    45180, len 84)

If you have pflog0 enabled (BSD pf firewall) you can watch your logged packets with:

# tcpdump -vvv -e -ttt -i pflog0

which uses an even more verbose output, includes the link-level header for each line, as well as the delta (in micro-seconds) between current and previous lines.