Simple Ping Sweeper for Linux

This script is a simple ping sweeper to identify hosts reachable from a system. The intent here is something simple and dirty that can quickly be manually created in the event I can’t use the normal tools and scripts. Obviously things like nmap would be much better here, but sometimes those tools won’t be available and you won’t be able to transfer them over.

!#/bin/bash

#Usage: Takes first 3 octects of network to sweep
#Example: pingsweep.sh 192.168.1

if [ “$1” == “” ] #space  between brackets is important
then
  echo “You forgot an ip address"
  echo “Syntax:”
  echo “Usage: Takes first 3 octects of network to sweep”
  echo “Example: pingsweep.sh 192.168.1”
else
  for ip in `seq 1 254`; do
    ping -c 1 $1.$ip | grep “64 bytes” | cut -d “ ” -f 4 | tr -d “:” &
  done
fi

Leave a Reply