How to Ping Multiple Hosts at High Performance with fping in Linux

Linux TLDR
Last Updated:
Reading time: 4 minutes

First, letโ€™s talk about the traditional ping command, its shortcomings, and how fping can fill those gaps before discussing the fping command.

If you are only interested in knowing about the fping command, then click here.

So, letโ€™s begin.

Short Intro of Traditional Ping Command

The traditional “ping” (Packet Internet Groper) command is used to send ICMP echo probes to network hosts (either local or global) by specifying their IP address or domain name as an argument to the “ping” command.

Once you receive the request from the host machine, you can conclude that the host is active and is able to communicate with your machine.

The following is an example of pinging the two different hosts separately via their IP address and domain name.

$ ping google.com
$ ping 31.13.79.35

Output:

Pinging two different hosts

Currently, both hosts are pinging separately, but the question is: can you ping them together in one command? Let’s try

$ ping google.com 31.13.79.35

Output:

Pinging two hosts separately using the ping command

As you can see from the above picture, the ping command has ignored the first host and started pinging the second (or last) “31.13.79.35” host.

Now, itโ€™s normal that thereโ€™s nothing you can do here except execute two different ping commands using the “&&” double ampersand and use the “-c” flag to specify the number of ping requests to be sent to each host.

$ ping -c 2 google.com && ping -c 2 31.13.79.35

Output:

Pinging two different hosts using the ping command in Linux

Congratulations on successfully pinging two different hosts with the ping command. Are you satisfied? Then you can leave this article here; however, I don’t find this way of pinging multiple hosts relevant.

And in such occasions where pinging multiple hosts is required, I prefer to use the fping command.

Tutorial Details

DescriptionA More Powerful Ping that can Ping Multiple Hosts.
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitesfping
Internet RequiredYes

What is the Fping Command in Linux?

The fping command is the oldest networking program still in use today. Roland Schemers published it in 1992 with the goal of sending high-performance ICMP echo probes to multiple network hosts at once.

In addition to that, this program has the ability to check multiple hosts, scan the entire network, and read IP addresses or domain names from a text file to check the existence of machines in a network.

๐Ÿ˜ฎ
The multiple hosts or range of hosts are scanned in round-robin fashion, and unlike the ping command, it can be used in shell scripts.

How to Install Fping in Linux System

Unfortunately, this amazing command-line tool is not shipped out of the box by Linux distributions, but you can install it from the default package manager.

Execute any one of the following commands to install it on your Linux system.

$ sudo apt install fping                                                                                      #On Debian or Ubuntu
$ sudo dnf install fping                                                                                      #On Red Hat or Fedora
$ sudo pacman -S fping                                                                                    #On Arch or Manjaro

Alternatively, you can install the current latest fping (5.1) version from the source package using the following commands:

$ wget https://fping.org/dist/fping-5.1.tar.gz
$ tar -xvf fping-5.1.tar.gz 
$ cd fping-5.1/
$ ./configure
$ make && make install

After the installation is complete, you can move on to the next section to learn the usage of the fping command.

Usage of the Fping Command

The fping command takes two arguments: one is the option, and the other is the hostnames.

$ fping [OPTION] [HOSTNAMES...]

Let’s see how you can use this command to ping multiple hosts.

Ping Multiple Hosts Using the Fping Command

To ping multiple hosts, all you have to do is specify each host as an argument to this command, using a space as a separator.

$ fping google.com 31.13.79.35 21.12.69.35

Output:

Pinging multiple hosts using the fping command

I think from the above picture you have understood that this command doesn’t give you additional information like “from“, “icmp_seq“, “ttl“, and “time” like the ping command does.

Ping Range of IP Address Using the Fping Command

The following command will scan and ping the range of IP addresses and return all the host information in the output.

$ fping -s -g 192.168.0.1 192.168.0.9

Output:

Scanning range of IP addresses

Ping a Complete Network Using the Fping Command

Unlike the previous command, the following command will scan your whole network and ping each of the hosts to check whether they are alive or not.

$ fping -g -r 1 192.168.0.0/24

Output:

Pinging the complete network

Read and Scan the Hosts from the Text File

Specifying each host as an argument to the fping command might not be inconvenient, especially when the list of hosts is very long.

However, you can save all the host names in a text file and pass the file name as an argument to the fping command using the “-f” flag.

$ cat hosts.txt
$ fping -f hosts.txt

Output:

Pinging hosts from the text file

Send N Echo Requests to Each Host

Using the “-c” flag, you can assign the number of echo requests to be sent to each host to check their availability on the network.

The following command will send the five requests to each host in the “hosts.txt” file.

$ fping -c 5 -f hosts.txt

Output:

Sending limited requests to hosts

Now most of the options are identical to the standard ping command that you can check by executing any one of the following commands:

$ fping --help
$ man fping

How to Uninstall/Remove Fping From Linux System

Execute any one of the following commands to remove it from your Linux system:

$ sudo apt remove fping                                                                                      #On Debian or Ubuntu
$ sudo dnf remove fping                                                                                      #On Red Hat or Fedora
$ sudo pacman -R fping                                                                                       #On Arch or Manjaro

So, let’s end this article here.

If you have questions or queries related to this tool, then leave them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.