Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tcpdump: localhost to localhost [closed]

I write a program that send TCP packets from localhost to localhost. And I want to use tcpdump to capture the packets. But nothing is captured. My command in Ubuntu:

sudo tcpdump 

What argument shall I add? Thanks!

like image 250
David Avatar asked Jun 28 '10 08:06

David


People also ask

How do I use tcpdump on localhost?

You can filter based on host using "host localhost" and you can filter based on ports using "tcp port 8081" . You can use first one for both ports to be TCP 8080 and 8081. You can use the second one for any port (source or dest) matching either 8080 or 8081.

How do I close tcpdump?

Use the Ctrl+C key combination to send an interrupt signal and stop the command. After capturing the packets, tcpdump will stop.

Does tcpdump set promiscuous mode?

Normally when capturing traffic with tcpdump , it puts the network interface into promiscuous mode. When not running in promiscuous mode, the interface only receives frames destined for its own MAC address as well as broadcast and multicast addresses.


1 Answers

sudo tcpdump -i lo 

Notes

  • If you get tcpdump: lo: No such device exists, get the name by coping it from the output of
sudo tcpdump -D 

For example, if the output is as below you need lo0 (which is reusult 9. here:

1.en0 [Up, Running] 2.p2p0 [Up, Running] 3.awdl0 [Up, Running] 4.llw0 [Up, Running] 5.utun0 [Up, Running] 6.utun1 [Up, Running] 7.utun2 [Up, Running] 8.utun3 [Up, Running] 9.lo0 [Up, Running, Loopback] 
like image 157
unbeli Avatar answered Sep 23 '22 05:09

unbeli