How To Ping Multiple IPs and Subnets In Linux Servers
Recently we showed you how you could ping multiple IPs with a simple bash script. Now we are going to show you how you can install Fping to achieve the same results. Roland Schemers released the first version of fping back in 1992. From 2002 till 2011 there was no new official new release but the software was maintained by end-users. Now a new maintainer has taken over the software and released version 5 of fping.
fping allows you to ping either single IPs, multiple IPs, IP ranges or Subnets from the command line of your NVMe VPS Server which then shows you if the IP is up or down. fping is a great tool for diagnostics and statistics.
How To Install FPING
At the time of writing this article, V5 of fping was the latest release. If you install fping using yum, apt, dnf or other OS install methods you will get v3 so to install fping v5 from the source, follow the instructions below. Ensure you have gcc installed before running the install commands.
wget https://fping.org/dist/fping-5.0.tar.gz
tar -xvf fping-5.0.tar.gz
cd fping-5.0
./configure
make && make install
fping should now be installed on your server and it’s time to start using the software. Let’s look at pinging single IPs with fping.
fping Single IP
fping 51.68.247.104
fping 51.68.247.104
51.68.247.104 is alive
Here I have sent ping requests to the IP 51.68.247.104 and fping has told me the IP is up and responding.
fping Multiple IPs
fping 51.68.247.104 51.68.247.105 51.68.247.106 51.68.247.107
fping 51.68.247.104 51.68.247.105 51.68.247.106 51.68.247.107
51.68.247.104 is alive
51.68.247.105 is alive
51.68.247.106 is alive
51.68.247.107 is alive
Here I have pinged multiple IPs and fping has reported they all respond. Entering all these IPs is time-consuming though. This is a subnet of 8 IPs, 51.68.247.104/29 so I could just ask fping to ping the whole subnet.
fping Subnet
fping -g 51.68.247.104/29
fping -g 51.68.247.104/29
51.68.247.104 is alive
51.68.247.105 is alive
51.68.247.106 is alive
51.68.247.107 is alive
51.68.247.108 is alive
51.68.247.109 is alive
51.68.247.110 is alive
51.68.247.111 is alive
Here I can see the whole subnet is up and it’s taken seconds because I can enter the subnet with no need to specify each IP. So what about a whole range of IPs? I could ping the subnet by entering the range too.
fping IP Range
fping -s -g 51.68.247.104 51.68.247.111
fping -s -g 51.68.247.104 51.68.247.111
51.68.247.104 is alive
51.68.247.105 is alive
51.68.247.106 is alive
51.68.247.107 is alive
51.68.247.108 is alive
51.68.247.109 is alive
51.68.247.110 is alive
51.68.247.111 is alive
8 targets
8 alive
0 unreachable
0 unknown addresses
0 timeouts (waiting for response)
8 ICMP Echos sent
8 ICMP Echo Replies received
0 other ICMP received
0.013 ms (min round trip time)
0.018 ms (avg round trip time)
0.024 ms (max round trip time)
0.071 sec (elapsed real time)
Using the -s flag gives you a greater output showing more statistics like the time it takes to ping each IP. If you have IP listed in a text file you can also tell fping to cycle through the whole file and provide you with the results.
fping Multiple IPs In Text File
fping < ips.txt
fping < ips.txt
51.68.247.104 is alive
51.68.247.105 is alive
51.68.247.106 is alive
51.68.247.107 is alive
51.68.247.108 is alive
51.68.247.109 is alive
51.68.247.110 is alive
51.68.247.111 is alive
Here I placed all my IPs into a text file called ips.txt and asked fping to ping each IP. You could add the -s flag (fping -s < ips.txt) to the command for full statistics. Overall fping is much much easier to use once the initial install of fping is complete.