C:\>for /l %i in (1,1,254) do @ping 192.168.1.%i -n 1 -w 100 | find "Reply"
This will ping all addresses from 192.168.1.1 to 192.168.1.254 one time each, wait 100ms for a reply (more than enough time on a local network) and show only the addresses that replied.
Syntax for FOR /L is (start,step,end) if you want to change the range.
Also, note that the Windows FIND is case sensitive, so make sure you capitalize "Reply," or else use the /i switch or just "eply."
This comment has been removed by the author.
ReplyDeleteThanks Florjan! I love this one!
ReplyDeleteGreetings, Matt
very useful!
ReplyDeletethis little line saved the world
ReplyDeleteExcellent one liner :D i'd like to point out that in a language specific non-english enviroment the "Reply" will yield no result.
ReplyDeleteChanging it to "TTL" will give a result in any language.
I like this solution a lot, thanks
DeleteHi, how would you adjust this to only show IPs that do not respond?
ReplyDeletefor /l %i in (1,1,254) do @ping 192.168.1.%i -n 1 -w 100 | find "timed out"
ReplyDeletefor /l %i in (1,1,254) do @ping 192.168.1.%i -n 1 -w 100 | find "timed out"
Deletethis request does not show which addresses timed out any ideas?
need to change wait time from - w 100 to something like 5000 depends on how quickly you get your timeout messages. Might also need to use "unreachable"
DeleteThank you for this post, helped a lot
ReplyDeletefor /l %i in (1,1,254) do @ping 192.168.1.%i -n 1 -w 100 | find "Reply" good job en.seo-hk.org
ReplyDeletefor /l %i in (1,1,254) do @ping 192.168.1.%i -n 1 -w 100 | find "Reply" good job en.seo-hk.org
ReplyDeletecan you use parameters like -a in the @ ping? I tried it but it didn't seem to work.
ReplyDeleteAnd to get an output file of it all?
ReplyDeleteJust add >>pinglist.txt or whatever filename to the end. (You need two >'s, otherwise each ping will overwrite the file)
ReplyDeleteI should apply myself more to the command line. So elegant and powerful. Thanks!
ReplyDeletewhat is difference between @ping and ping ...
ReplyDeleteand what is /L after for
The @ sign just makes the command not appear. Without it, you would see each ping command written to the screen.
DeleteThe "for /l" is a loop and operates on (start, step, end). Without the /l it would expect file and directory names.
what is mean (start,step,end)
ReplyDeletebest dos command of all times
ReplyDeleteDoes anyone know whether it's possible to run a single line command for a subnet larger than a /24? Altering the step change isn't an option as there's no IP intelligence there so it just starts pinging .256, .257, .258 etc. as opposed to incrementing the third octet and starting afresh from whatever your starting point is.
ReplyDeleteYou would have to do a nested loop and expand slightly:
Deletefor /l %i in (0,1,7) do @for /l %j in (0,1,255) do @ping 192.168.%i.%j -n 1 -w 100 | find "Reply"
This will ping 192.168.0.0 through 7.255. Obviously, it will actually try to ping the ID and the broadcast, but there's no way around that.
Thanks Joe :)
DeleteIt was actually a mass rDNS lookup I was looking to perform so achieved this as follows (it was the nested loop I needed though so thanks!):
FOR /L %i IN (124,1,127) DO @for /l %j in (0,1,255) do nslookup xxx.xxx.%i.%j x.x.x.x | FINDSTR /r "Name Address">>c:\rdns.txt
I could probably have done with omitting entries that didn't resolve from the results but it did the job :)
Great man...thanks a lot
ReplyDeleteThank you Joe :-)
ReplyDeleteI was wondering; is there a way to request host names of responding IP's at the same time?
Sure thing! Just add "-a" to the ping command. It'll slow things down a bit, and it's not always reliable, but that's all we can do.
Deleteis is possible to ping multiple host name by above com line.
ReplyDeleteE.g edit all host name by xx.txt then ping them
Awesome!
ReplyDeleteIs it possible to change you computers IP address, Netmask and Gateway from the command prompt ?
ReplyDelete