Detecting devices on a local network using ping

I'm borrowing this idea from here. If you continue reading the post you'll find many innovative ideas in the comments but I just have a slight improvement to the original line of batch code:

Linux
for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done
You can speed things up by adding the -W parameter to the ping command to decrease the timeout to 1 second instead of the default which is 3 seconds.
for ip in $(seq 1 254); do ping -W 1 -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done

...for windows
for /L %I in (1,1,254) DO ping -w 30 -n 1 192.168.1.%I | find "bytes="

Comments

Popular posts from this blog

Testing SOAP services using pingdom