tcpdump: localhost to localhost

LinuxLocalhostTcpdump

Linux Problem Overview


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!

Linux Solutions


Solution 1 - Linux

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]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDavidView Question on Stackoverflow
Solution 1 - LinuxunbeliView Answer on Stackoverflow