Main Menu

Search

LINUX: Ping Command To Ping Range of Sequential IP Addresses or Hostnames at the Same Time Simultaneously (How To Doc)

Below Ping command can be used to ping range of Sequential IP addresses at the same time simultaneously. In below ping command the sequential IP addresses we are pinging are 10.10.10.1 till 10.10.10.10. i variable defined in below command is the last octet of the IP addresses in sequence.
# for i in {1..10}; do ping -c 1 -t 1 10.10.10.$i > /dev/null 2>&1 && echo "Ping Status of  10.10.10.$i : Success" || echo "Ping Status of  10.10.10.$i : Failed" ; done

Below is example snippet of above command.

# for i in {1..10}; do ping -c 1 -t 1 10.10.10.$i > /dev/null 2>&1 && echo "Ping Status of  10.10.10.$i : Success" || echo "Ping Status of  10.10.10.$i : Failed" ; done
        Ping Status of  10.10.10.1 : Success
        Ping Status of  10.10.10.2 : Success
        Ping Status of  10.10.10.3 : Success
        Ping Status of  10.10.10.4 : Success
        Ping Status of  10.10.10.5 : Success
        Ping Status of  10.10.10.6 : Success
        Ping Status of  10.10.10.7 : Failed
        Ping Status of  10.10.10.8 : Success
        Ping Status of  10.10.10.9 : Success
        Ping Status of  10.10.10.10 : Failed

In case you want to test the ping to the hostnames you can use the same command as follows:

# for i in {1..5}; do ping -c 1 -t 1 testhost$i > /dev/null 2>&1 && echo "Ping Status of  testhost$i : Success" || echo "Ping Status of  testhost$i : Failed" ; done

In above command we assume the hostname starts with testhost1 and goes till testhost5. Below is sample output of above command.

        Ping Status of  testhost1 : Success
        Ping Status of  testhost2 : Success
        Ping Status of  testhost3 : Success
        Ping Status of  testhost4 : Success
        Ping Status of  testhost5 : Failed

Products to which Article Applies



All Linux Operating Systems.


Additional References


https://smallbusiness.chron.com/ping-ip-addresses-lan-68381.html
https://etherealmind.com/tech-notes-ping-sweep-ip-subnet/


 



tarun boyella

No comments:

Post a Comment