One-click Batch ping of any IP segment of the surviving host

Source: Internet
Author: User

One-click Batch ping of any IP segment of the surviving host


Continue with our Computer Batch series tutorial tonight. If you want to know your own community broadband or local area network, or even an arbitrary IP segment outside the network, how many people at the same time in the Internet swollen? Maybe we all think about finding tools or something. In fact, the use of Windows built-in batch processing can fully realize the purpose of batch ping to find the designated network Segment Survival host!

@echo off
Color E
Title Batch Sweep Network segment host
Echo.
@for/F "tokens=1-4 delims=."%%i in (ip.txt) do (@for/L%%n in (1,1,255) do @ping-W 600-n 1%%i.%%j.%%k.%%n|find/i "t TL ")
Echo.&echo Scan complete, press any key to exit ... &pause>nul

Copy the above code into the Notepad document, then save as batch ping.bat, and then create a blank text document and rename it to Ip.txt. All ready to finish, you can batch scan the address of the IP segment into ip.txt (for example, to sweep their corresponding intranet IP segment can be entered in the Ip.txt 192.168.1.1 after saving), and then double-click a key to run the batch Ping.bat The batch script can see the returned results. The format is similar to:

Reply from 192.168.1.1:bytes=32 time=2ms ttl=64
Reply from 192.168.1.2:bytes=32 time=3ms ttl=64
Reply from 192.168.1.3:bytes=32 time=2ms ttl=64
Reply from 192.168.1.5:bytes=32 time=2ms ttl=64
Reply from 192.168.1.6:bytes=32 time=1ms ttl=64
...... Omit all the possible results from the rest ...

Let me read a batch command that looks a little hard. Let's take a look at this, ping-w. 600-n 1 means pinging the specified IP address once, waiting for a timeout of 600 milliseconds, |find/i "ttl" refers to the result of only displaying a "TTL" string in the ping return result, that is, filtering out hosts that do not live within the specified network segment. The front @for/F "tokens=1-4 delims=."%%i in (ip.txt) means to "Ip.txt" the string (that is, the address of the IP segment we are looking for) with "." The boundary is divided into four parts, which are given the following variables%%i,%%j,%%k respectively. The last remaining @for/L%%n in (1,1,255) indicates that the loop +1 increments from 1 to 255 stops and then assigns the variable%%n. You can enter for/in the CMD window if you can't read it. Take a look at the command.

One-click Batch ping of any IP segment of the surviving host

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.