License Public Domain
Lines 10
Keywords
ping (1) subnet (1)
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

Ping Every IP in a Subnet Atom Feed 0

In Brief Pings every IP in the 192.168.xxx.xxx subnet; the particular subnet to ping can be changed of course.... more
# 's
 1for ((i=0;i<255;i+=1)); do
2 for ((j=0;j<255;j+=1)); do
3 #echo "ping -a -c 3 192.168.$i.$j"
4 if ping -a -t 1 192.168.$i.$j > /dev/null; then
5 echo "Success: 192.168.$i.$j"
6 else
7 echo -n "*"
8 fi
9 done
10done

Pings every IP in the 192.168.xxx.xxx subnet; the particular subnet to ping can be changed of course.

Waits 1 second for reply. (To change use the -t argument to ping.) Prints a success message if pingable, otherwise a '*'.

Comments

over 8 years ago (30 Dec 2008 at 02:46 PM) by Stou S.
One could do this with nmap using a ping scan: `nmap -sP 192.168.*.*`

There's also a broadcast ping: `ping -b 192.168.1.255` which doesn't seem to work too well =)
over 8 years ago (02 Jan 2009 at 03:24 PM) by David Isaacson
Awesome... way easier, assuming I have nmap on my system... (pause)... which I don't. (Go Macs!)

Virtually nothing (except for macs!) responds to broadcast pings for some reason, although it's probably more secure that way.
over 8 years ago (02 Jan 2009 at 03:24 PM) by David Isaacson
BTW, no plug for fe3d being a great solution? I'm kind of disappointed :-D
over 8 years ago (02 Jan 2009 at 04:52 PM) by Stou S.
Oh snap, yes, the best solution is to download fe3d from http://projects.icapsid.net/fe3d then Right Click in the window and select 'Scan' then the 'Ping Scan' option, enter the IP range like: nmap -sP 192.168.*.*

It will probably crash but hey... it's cool++
over 8 years ago (02 Jan 2009 at 04:54 PM) by Stou S.
oh... and you have to have nmap installed before you can run fe3d. Good luck.