Home Linux Networking How To Ping Multiple Hosts At Once In Linux

How To Ping Multiple Hosts At Once In Linux

By sk
Published: Last Updated on 29.7K views

We all know about PING (Packet INternet Groper) network commandline utility, right? Ping is used to verify a host can able to communicate over the Network with another Computer or Network devices. Using Ping command, we can send ICMP Echo request to our target host, and test whether the destination host is alive or not. We can ping systems in LAN and WAN. The ping utility was originally written by Mike Muuss in December 1983 for troubleshooting problems in the network.

A typical usage of ping command is given below.

To ping an IP address in a LAN, run:

$ ping 192.168.1.100

Sample output:

ping an ip address

ping an ip address

To ping a host / domain / website:

$ ping ostechnix.com

Sample output:

ping a website

ping a website

As you see in the above outputs, both hosts are alive, and we can able to communicate with them.

The one problem with PING command is we can't ping multiple hosts at a time. We can only ping one system at a time.  If you ping to multiple hosts (or ping multiple IP addresses), the PING utility will wait for one host's timeout or reply, and try to communicate with the another. If one host doesn't go down, the PING utility will keep showing a particular host's connectivity, and It will not show whether the other hosts are up or down.

Let me show you an example. I am going to ping the following hosts.

  • 192.168.1.100
  • ostechnix.com
  • google.com
  • ubuntu.com

To do so, run:

$ ping 192.168.1.100 ostechnix.com google.com ubuntu.com

Sample output:

ping multiple hosts

ping multiple hosts

As you see in the above output, the PING utility shows only one host's connectivity (ubuntu.com), and it doesn't show the results of other hosts. No worries! Here is where fping utility comes in handy. Using fping utility, we can ping any number of hosts at once.

What is fping?

fping is similar to PING utility that can used to test the connectivity of computers and network devices in LAN and WAN. Unlike PING command, fping will send a ICMP Echo request to one host, and move to the another host in a round-robin fashion.

Using fping, we can ping multiple hosts or multiple IP addresses at once.

Install fping in Linux

fping utility is available in almost all modern Linux/Unix operating systems.

To install fping on Arch Linux, run:

$ sudo pacman -S fping

On Debian / Ubuntu:

$ sudo apt-get install fping

On Fedora RHEL / CentOS / AlmaLinux / Rocky Linux:

$ sudo dnf install epel-release
$ sudo dnf install fping

Ping Multiple Hosts At Once Using fping In Linux

fping usage is simple and very similar to PING command.

For example, let us ping an IP address in a LAN:

$ fping 192.168.1.100

Sample output:

192.168.1.100 is alive

To ping multiple hosts or multiple IP addresses, run:

$ fping 192.168.1.100 ostechnix.com google.com ubuntu.com

Sample output:

192.168.1.100 is alive
google.com is alive
ubuntu.com is alive
ostechnix.com is alive
Ping Multiple Hosts At Once Using fping In Linux

Ping Multiple Hosts At Once Using fping In Linux

Also, you can put the hosts that you want to ping in a text file, and ping them all at once.

Let us create a new text file called ping_hosts.txt.

$ nano ping_hosts.txt

Add the list of hosts, IP addresses, domains, websites etc.

192.168.1.100
192.168.1.150
ostechnix.com
www.google.com
www.ubuntu.com
www.centos.org

That's enough. Save and close the file.

Now, run the following command to ping all hosts which we mentioned in the text file as shown below.

$ sudo fping -f ping_hosts.txt

Sample output:

192.168.1.100 is alive
192.168.1.150 is alive
www.google.com is alive
www.ubuntu.com is alive
www.centos.org is alive
ostechnix.com is alive

Sample output:

Ping Multiple Hosts At Once With fping In Linux

Ping Multiple Hosts At Once With fping In Linux

Cool! It works.

For more details, check man pages.

$ man fping

Suggested read:

You May Also Like

4 comments

AlekseyShi March 31, 2016 - 3:20 pm

fping functionality is not the same as ping. fping doesn’t show any details of ICMP pinging instead of ping.

Reply
SK March 31, 2016 - 7:35 pm

Yes. The usage is same.

Reply
Rizwan Mohammed April 1, 2017 - 10:40 pm

we can also use the traditional ping command as ping -c5 8.8.8.8 && ping -c5 ostechnix.com to ping multiple addresses

Reply
MIKE October 18, 2020 - 2:30 am

Excelent thank you very much

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More