How to check IPs respond – Ping Multiple IPs
Many users have multiple IPs assigned to their Dedicated Server and KVM VPS server. On our KVM plans users can have a maximum of 64 additional IPs or on a dedicated server users can have a maximum of 250 IPs and when users have multiple IPs assigned to their servers they want a way to check that all their IPs are functioning without having to ping each individual IPs.
Ping IP Or Multiple IPs With Bash
A simple bash script can be used to ping multiple IPs. We have provided a quick script below. To use the script just copy the code to a new file on your server. This does not have to be run by the root user.
Now, copy the below code the file.
#!/bin/bash date cat ping.txt | while read output do ping -c 1 "$output" > /dev/null if [ $? -eq 0 ]; then echo "IP $output is up" else echo "IP $output is down" fi done
Save and close the file. Next place all of the IPs you want to ping in a new file called ping.txt. This file should be in the same directory as the pingall.sh file.
The file will now have a list of IPs. One IP per line.
220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168
Finally, you can run the script with the below command. This will cycle through each IP in the ping.txt file returning whether the IP is up or down.
sh pingall.sh Tue Aug 18 10:37:33 UTC 2020 IP 22.214.171.124 is up IP 126.96.36.199 is up IP 188.8.131.52 is up IP 184.108.40.206 is up IP 220.127.116.11 is down IP 18.104.22.168 is up IP 22.214.171.124 is up IP 126.96.36.199 is up
Blacklist & Heartbeat Tracking
This quick script does not provide any sort of log or output other than telling you if an IP is up or down. If you want a professional way to monitor your IPs for outages, RBL blacklists with a full log of uptime and alerts via SMS and email consider using our Blacklist & Heartbeat tracking service. Every customer can order the free or paid plan from your client area. This service allows you to monitor the uptime of SolusVM nodes, custom ports or services like email, ssh or MySQL.
How was this article?