Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture the packet from same machine with tcpdump on Linux? [closed]

Tags:

linux

tcpdump

My computer has only one network card. I have a program listening on one port. I intend to send one packet on the same machine, my program can receive the packet. I can't capture the packet by tcpdump on the machine which my program is running on.

If I send packet from another machine, tcpdump can capture the packet.

like image 478
Hardy Feng Avatar asked Feb 27 '14 10:02

Hardy Feng


People also ask

How to use tcpdump to capture packets from a specific interface?

When we run the tcpdump command without any options, it will capture packets on the all interfaces, so to capture the packets from a specific interface use the option ‘ -i ‘ followed by the interface name. Syntax : # tcpdump -i {interface-name}. Let’s assume, i want to capture packets from interface “enp0s3”.

What is tcpdump in Linux?

tcpdump is a packet sniffing and packet analyzing tool for a System Administrator to troubleshoot connectivity issues in Linux. It is used to capture, filter, and analyze network traffic such as TCP/IP packets going through your system.

How to analyze TCP/IP packets in Linux?

tcpdump is a well known command line packet analyzer tool. Using tcpdump command we can capture the live TCP/IP packets and these packets can also be saved to a file.

How to capture packets from a specific network interface in Linux?

sudo tcpdump This will capture the packets from the current interface of the network through which the system is connected to the internet. 2. To capture packets from a specific network interface


1 Answers

If i understand you correctly, you send the packet from a machine to itself. If so, you need tcpdump on the loopback interface. e.g.

tcpdump -i lo
like image 158
Benav Avatar answered Nov 03 '22 01:11

Benav