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!
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.
Use the Ctrl+C key combination to send an interrupt signal and stop the command. After capturing the packets, tcpdump will stop.
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.
sudo tcpdump -i lo
tcpdump: lo: No such device exists
, get the name by coping it from the output ofsudo 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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With