Skip to content

Instantly share code, notes, and snippets.

@jbcdnr
Created December 29, 2016 17:14
Show Gist options
  • Save jbcdnr/a956ca808e951b353f2d34b2b362e5f1 to your computer and use it in GitHub Desktop.
Save jbcdnr/a956ca808e951b353f2d34b2b362e5f1 to your computer and use it in GitHub Desktop.
Ping a range of addresses
#!/bin/sh
# source http://www.stealthcopter.com/blog/2010/01/bash-script-to-find-active-computers-in-a-subnet-using-ping/
: ${1?"Usage: $0 ip subnet to scan. eg '192.168.1.'"}
subnet=$1
for addr in `seq 0 1 255 `; do
# ( echo $subnet$addr)
( ping -c 3 -t 5 $subnet$addr > /dev/null && echo $subnet$addr is Alive ) &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment