November 12, 2023
Many friends of weak current engineers often encounter some network glitches in a project. Nowadays, everyone will use ping to find and locate a point of failure.
But what if there are too many devices? Pinging one at a time is a waste of time and energy. Yianfang teaches you a little trick, even if you have 1000 devices, you won't be afraid.
Batch scan of network segments
Enter code directly in command prompt window:
for /L %D at (1,1,255) ping 10.168.1.%D
Change IP address segment to IP address segment you want to check. When you issue a batch command, it will automatically ping all IP addresses on network segment.
Command update, search for "TTL=" in .txt file
Enter code in command prompt window:
for /L %D at (1,1,255) ping -n 10.168.1.%D >>a.txt
Note: The IP address is changed, just fill in IP network segment for testing, .txt is also changed, you can set name.
This will import results into a .txt file, open and search for "TTL=", address containing it is a passable address, and address that does not contain "not passable.
Repeated update split into two files
Enter code in command prompt window:
for /l %D at (1,1,255) do (ping 192.168.1.%D -n 1 && echo 192.168.1.%D>>ok.txt || echo 192.168.1.%D >> №.txt)
This code will put pinged IP address and unreachable IP address into two files respectively, which looks very handy.
Best method: discovering IP addresses of different network segments at same time
What if you need to determine IP addresses of different network segments at same time?
Enter following code:
for /f %D in (ip.txt) do (ping %D -n 1 && echo %i>>ok.txt || echo %D >>no.txt)
Note. There is an additional ip.txt file in code. This file must be prepared by yourself. Write your ping address into this file and code will read IP address into this file on its own. , and put results in two files.
Did you receive above tips? Learn fast.