Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to Ping many IP addresses at the same time, a little trick to save N hours?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Ping command is the most commonly used command for us to check the network. As network personnel, it is basically used every day, which can help us to analyze and determine network faults. What if there are 10 devices, 100 devices and 1000 devices? Ping in the past people are going crazy, this kind of situation we may encounter in a large network, then how to do?

I. batch ping network segments

For a network segment with a large number of ip addresses, if a single detection is really troublesome, then we can directly batch ping network segment detection, which ip address has a problem, at a glance.

First look at the code and enter it directly in the command line window:

For / L% D in (1jie 1255) do ping 192.168.1% D

Change the IP address field to the IP address field you want to check.

When a batch command is entered, it automatically ping all the ip addresses in the network segment.

So what does this "for / L% D in (1JI 1255) do ping 192.168.1% D" code mean?

The one in the code (1re1255) is the beginning and beginning of the network segment, that is, it detects all the ip addresses of the network segment from 192.168.1.1 to 192.168.1.255, increasing by 1 at a time, directly to the end of the detection of the 255 ip from 1 to 255.

II. Upgrade of batch ping network segment commands

Although the above command can batch ping addresses, the above code also looks troublesome when a large number of command line windows are displayed, so let's upgrade it again and use the following code.

For / L% D in (1mem1255) do ping 10.168.1% D > > a.txt

Note, ip address is changed, you need to fill in the ip network segment you need to test on the line, a.txt is also changed, you can set your own name.

In this way, the results will be imported into the a.txt file, and after all the IP checks are completed, open the a.txt search for "TTL=" that contains the address of the pass, and the address that does not contain the "TTL=" is not allowed. The figure below is as follows

After opening it, just search for those without TTL.

Third, upgrade the batch ping network segment command.

Many people want to say that it is not very convenient to search in this way, and they need to check it out in this way, so let's take a look at it again and see if there is a simpler way to do it.

The answer must be yes. Let's look at the code.

For / l% D in (1Power1255) do (ping 192.168.1% D-n 1 & & echo 192.168.1% D > > ok.txt | | echo 192.168.1% D > > no.txt)

This code will put the IP and the impassable IP of ping into two files respectively. Is this convenient, as shown in the following figure:

This code is very practical and can be used in a large network, that is, you need to be careful when typing, but it doesn't matter. You can collect this article directly, use it in the future, copy the code directly, and then change the ip address on the line.

Fourth, the ultimate method of batch ping network segment command

The three codes mentioned above are all for batch detection of ip addresses in the same network segment, so it is certain that in the actual project, the ip addresses of different network segments may also need to be detected at the same time.

There is also a way to detect unplanned ip addresses in batches at the same time. Let's take a look at the code:

For / f% D in (ip.txt) do (ping% D-n 1 & & echo% D > > ok.txt | | echo% D > > no.txt)

See that there is an extra ip.txt file, this file is to be prepared by yourself, write your ping address into this file, the code will read the ip address inside this file, and put the results into two files. I won't take a screenshot here. It's similar to the picture above.

I would like to add:

The files generated by the above code are in your command line default directory, that is, if your command line status is "c:\ windows\ system32 >", then the generated files are in the system's system32 directory. If it is "c:\" then the file is in the root directory of disk C. This can be adjusted according to your own actual situation.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report