Ping command in Linux with examples

Originally published at: ping command in Linux with examples

This ping command guide follows my previous 90 Linux Commands frequently used by Linux Sysadmins article. As time allows, I will continue to publish articles on the 90+ commands geared toward Linux sysadmins and Linux power users. Let’s continue this series with the ping command. The Linux command line is a treasure trove of powerful tools that can help you…

Hey. Does flood ping do parallel asynchronous pings, or just continuous?

If you have a patchy internet connection, like a wi-fi hotspot connection to a 'phone in a poor reception area, it’d be nice to know how to monitor the connection to catch it as soon as the line to the ISP restores. Would ping be a good candidate for such a purpose?

2 Likes

Hi @AnthonyRKing Good question!!

Flood ping doesn’t perform parallel asynchronous pings, instead it sends packets as fast as possible repeatedly. While it can help monitor network stability, it may not be ideal for patchy connections. Instead, consider using regular ping with a shorter interval to monitor the connection:

ping -i 0.5 example.com

This way, you can quickly detect when the line to the ISP restores, making it a better candidate for such purposes.

You can also consider using “mtr” (My TraceRoute). MTR combines the functionality of “ping” and “traceroute” and provides real-time information on both latency and route changes, making it a useful for monitoring and diagnosing intermittent connectivity issues.

I’ll write an article for mtr next, in the meantime, see: mtr - Network Diagnostics - Documentation

If you are using your phone to monitor check out fing.com. I like using GitHub - orf/gping: Ping, but with a graph on desktop.

1 Like

Very good; I’ll look forward to that then. The other thing to eliminate, or compare to, would be the Wi-Fi connection. You don’t get a router dashboard from a hot-spot (as far as I am aware), so I could also be pinging the device serving the hot-spot. It’s not obvious how to get an IP address for it though.

1 Like

I understand what you mean.

Hm… If you download Fing on your smartphone. It will scan the entire Wi-Fi network you connect to and give you the IP address to most everything that’s connected on that network. Give it a try and see if it’s does.

Well - I’m finding just using ping 8.8.8.8 pretty helpful (and easy to remember), and it’s a native command, which is more attractive to me initially, than a phone app.

With this, I can easily see when the connection is really broken, and also can infer when a page load has got stuck and needs refreshing.

1 Like

There is something that should be remembered when the ping command is used:

To communicate, the ping command uses ICMP (Internet Control Message Protocol). It is like TCP or UDP but a different protocol.

Because it is a connection protocol, it can be blocked by firewalls. Some system admins block this protocol because they don’t want their servers to be scrapped by server search engines like Shodan.

So, if your ping request does not reach the server, this may be due to the server’s firewall settings.

P.S.: If you want to know more about ICMP you can check out this link:

1 Like

@hydn @serhattsnmz didnt saw this post but a great post read this morning, so coded this. An automate ping iterator and also a terraform ping associator that will create the template file and associate the ping address with it.

for i in $(cat list | cut -f 2 -d " "); do echo ping -i $i; done 
template="template text {  }"
for i in $(cat list | cut -f 2 -d " "); do echo printf "%s${template}"_"$i"; done 

You can invoke as many templates you want. You can find the entire code in the shell_terraform respository in my github which i am pushing this soon.

alles gut,
Gaurav

1 Like