Search

Ping number of IPs with just one script!

Ping allows you to check if the IP address verify if the host is up or not. Ping is used by system administrators and even network security professionals. However, if you have a long list of IP addresses to be verified, it can turn out to be very annoying. Here scripts come to rescue!!

Using shell scripting a person can ping a range of IP addresses or even the whole subnet at the same time. Isn’t it a whole lot easier now?

You can do this using a simple script which we have shown below:

Note: We have written this script using sublime text and saved it with extension “.sh”

I would like to explain this script a little bit so that you can customize it according to your needs.
 seq is used to indicate the range of IPs that you wish to scan ( I used seq 1 254, allowing me to scan the whole subnet) you can adjust it according to your requirements.

-c is used to set the count (I used it as -c 1, which limits me to ping each IP once). It is recommended to use count as 1 because it will create unnecessary ping requests.

$SUBNET.$IP combines the subnet which I have provided with the seq of IP. Again! You can be creative here according to your needs.

 

After saving the script go to the terminal and make it executable using the command “chmod +x” and run using ./pingsweep.sh and then enter your desired IP. (Enter only first three bits of the network as the last bit will be taken from the script).
Finally! You can see that we are able to ping number of IPs with just one command.

Author: Mohammad Usman Rais (IT Security Engineer)

Table of Contents

Social Media
Facebook
Twitter
WhatsApp
LinkedIn