01

How do I automatically ping a specific network segment in batches

I don’t know if you have ever encountered this kind of scene, especially if you have ever lived in the field, you should have encountered it. Customer A say: huang gong, just sent an IP address excel form, help ping once, which address is impassable, which address is through?

Then, you open the form and look:

Hundreds of IP addresses, let me ping !!!! Is this trying to kill my rhythm? Let me cry for a while. At noon, everyone else went to dinner, I can only ping there one by one?

As you can see from this article, the above situation will never appear again. Teach you a command, and the next time the customer comes back, you can brag about it.

From CMD, enter the following code on the command line:

For /L %d in (1,1,255) do ping 192.168.1.%d

192.168.1.%d: CHANGE the IP address to the IP address you want to ping.

After entering the command, the system automatically pings all IP addresses in the network segment 192.168.1.1-255 in batches.

Now, let’s explain some of the important parameters.

%d: indicates the meaning of a variable.

(1,1,255) : The first 1 indicates the starting value, which is 1. The second one is the increment value, how much you increment the previous one at a time. This is plus 1. 255: indicates the last value to end.

Now, I change the first 1 to 10 to see what happens:

Let’s go back to the second 1 mentioned earlier and try changing it to 3:

02

How to save ping results to TXT automatically

Well, that’s the thing about people. Automatic ping is good enough. Still not satisfied, but also want to be able to ping results automatically saved in the file.

If you all want it, what can I do? Can only satisfy you ~

Simply add a few more characters to the command above and you’re done.

For /L %d in (1,1,255) do ping 192.168.1.%d >> long.txt

TXT: along is the name of the file I picked randomly.

After the command is executed, if you cannot find the file, you can search for it.

03

How to extract the IP address from ping results and retain the IP address?

After using the above command, some people may feel very troublesome ah, I also have to go to see. Can you make a command to execute, which through THE IP directly saved to a TXT text, which is not IP directly saved to another TXT file ah?

The answer is yes. The command is as follows:

For/l % D,1,255 (1) in the do (ping 192.168.1. % D – n 1 && echo 192.168.1. % D > >. TXT | | echo 192.168.1. % D > >.)

After the command is executed, the IP addresses that ping through and that cannot be pinged are saved to two files respectively. How’s that? Does this command work? Should we add a drumstick to Aaron?

04

What if you want to ping a network segment?

Look at the above several examples, someone said: scum, you can only access the network segment, no egg use. What about different network segments? Can you handle it?

Answer: Yes. You need to organize an IP file first.

The command is as follows:

For/f % d (in IP. TXT) do (ping – n && echo % 1 d % d > >. TXT | | echo % d > >.)

Have you seen more than an IP.txt file, this file is to prepare your own oh, ping your address to this file inside, the code will read the file inside the IP address, and put the result into two files inside.

See no more than an IP.txt file, this file is to prepare your own oh, ping your address to this file inside, the code will read the file inside the IP address, and put the result into two files inside.

Mp.weixin.qq.com/s/y8-TbqOKG…

Refer to the website: www.cnblogs.com/xiaorongjie…