This command will ping every ip from 192.168.2.1 to 192.168.2.255
for /L %i in (1,1,255) do ping -w 20 -n 1 192.168.2.%i | find /i "Reply"
The above command would return would be similar to this, showing a reply for IPs that return a ping.
C:>ping -w 20 -n 1 192.168.2.1 | find /i "Reply"
Reply from 192.168.2.1: bytes=32 time<1ms TTL=64
C:>ping -w 20 -n 1 192.168.2.2 | find /i "Reply"
C:>ping -w 20 -n 1 192.168.2.3 | find /i "Reply"
Reply from 192.168.2.3: bytes=32 time<1ms TTL=64
C:>ping -w 20 -n 1 192.168.2.4 | find /i "Reply"
Reply from 192.168.2.4: bytes=32 time<1ms TTL=64
C:>ping -w 20 -n 1 192.168.2.5 | find /i "Reply"
C:>ping -w 20 -n 1 192.168.2.6 | find /i "Reply"
C:>ping -w 20 -n 1 192.168.2.7 | find /i "Reply"
C:>ping -w 20 -n 1 192.168.2.8 | find /i "Reply"
Reply from 192.168.2.8: bytes=32 time<1ms TTL=64
Here are some adjustments
Ping a range 1-100:
for /L %i in (1,1,100) do ping -w 20 -n 1 192.168.2.%i | find /i "Reply"
Ping a range 100-200:
for /L %i in (100,1,200) do ping -w 20 -n 1 192.168.2.%i | find /i "Reply"
Range 1 to 200, but ping every second value
for /L %i in (1,2,200) do ping -w 20 -n 1 192.168.2.%i | find /i "Reply"
Here's how the command works:
for /L %i in (1,1,255) do ping -w 20 -n 1 192.168.2.%i | find /i "Reply"
Do a loop of pings from 1, counting up 1 each time, until you reach 255, while waiting for only 20 ms and for only 1 response on the specified network of 192.168.0.XXX.
To specify From A to B is in the (1,1,255) translates to (A,X,B)/ the W indicates how many milliseconds to wait for a response before you continue. I keep it low, usually since i'm pinging on a local lan, but if you find results aren't accurate, turn up the rate to 100 (or eliminate the -w 20 all together to wait longer.
A= starting point B= Ending point X= Increment value (normally would be 1)
No comments:
Post a Comment