linux – Utility for Performing ICMP Testing (“Ping”) in One Direction

icmplinuxnetworking

I've been having trouble with some network configuration lately which has been tricky to resolve.

It seems this would be much easier to diagnose if I knew which direction the traffic was failing to get through. Since all ping requests receive no responses back I'd like to know if the ping-request packets are getting through and the responses failing, or if it's the requests themselves that are failing.

To be clear, standard utilities like ping and traceroute rely on sending a packet out from one machine and receiving a packet in response back to that same machine. When no response comes back, it's always impossible to tell if the initial request failed to get through, or the response to it was blocked or even if the response to it was simply never sent. It's this specific detail, "which direction is the failure", that I'd like to analyse.

Are there any utilities commonly available for Linux which will let me monitor for incoming ICMP ping requests?

Best Answer

tcpdump can do this, and is available pretty much everywhere:

tcpdump -n -i enp0s25 icmp

will dump all incoming and outgoing ICMP packets on enp0s25.

To see only ICMP echo requests:

tcpdump -n -i enp0s25 "icmp[0] == 8"

(-n avoids DNS lookups, which can delay packet reporting and introduce unwanted traffic of their own.)

This allows you to find if it is receiving the packets from the other machine (from which you would e.g. ping it), so the problem is with the return path, or if they directly don't arrive.

Related Question