Friday 6 March 2015

Search a whole network for pingable devices

Sometimes it can be handy to check what devices are live on a network. You can just ping your broadcast address with Windows and that will work (albeit in whatever order the devices respond to you) but of course what if you want to quickly scan another network? You can't ping a broadcast address for a network your PC is not actually on. Don't worry however as it's easily done with a quick command

Simply run this command and you'll find a text file with all the answers (this file will only contain the IP addresses which have responded). Just change the details to suite your network.

FOR /L %i IN (1,1,254) DO ping -n 1 192.168.1.%i | FIND /i "Reply" >> c:\foundyou.txt



The brackets in the command contain the finer details. The first number is the IP you want to start with (in this case 1 so the ping will do 192.168.1.1) and the second number is the incremental amount you want to add to ping the next IP. So dThe 2nd number is 1 so the next IP to ping will be 192.168.1.2. If we were to have put a 2 there then it would be 1 + 2 so the next IP to ping would of been 192.168.1.3. Finally the last number is the last number to get to and stop. In our case it is 254 so we would have ping'd every IP in the subnet of 192.168.1.x/24. If we only wanted to ping 192.168.1-25 then we'd change the last number to 25.

Also just change the file path to somewhere you can actually save files to or you'll get an access is denied error...unless of course you do a Run as administrator for your command prompt. Now while this is running, it's a perfect time to get a quick pint in at the local!

No comments:

Post a Comment