Operations 6 min read

What Happens When You Ping Hundreds of IPs at Once? A Step‑by‑Step Batch Ping Guide

This article walks through using Windows command‑line loops to batch‑ping large IP ranges, showing how to iterate subnets, capture results in files, separate reachable from unreachable hosts, and handle arbitrary IP lists for efficient network troubleshooting.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
What Happens When You Ping Hundreds of IPs at Once? A Step‑by‑Step Batch Ping Guide

When dozens or hundreds of devices must be checked, issuing individual ping commands is impractical. Windows command‑line loops can batch‑ping entire subnets or arbitrary IP lists.

Batch ping a contiguous /24 subnet

Use a for /L loop where the three numbers represent start, step, and end values. The command below pings every address from 10.168.1.1 to 10.168.1.255:

for /L %D in (1,1,255) do ping 10.168.1.%D

Save raw ping output to a file

Redirect each ping’s console output to a text file. After the loop finishes, searching the file for the string TTL= identifies reachable hosts (lines containing the string) and failures (lines without it).

for /L %D in (1,1,255) do ping -n 10.168.1.%D >> a.txt

Separate reachable and unreachable IPs

Conditional execution ( && and ||) writes successful and failed addresses to different files in a single pass:

for /L %D in (1,1,255) do (ping 192.168.1.%D -n 1 && echo 192.168.1.%D>>ok.txt || echo 192.168.1.%D>>no.txt)

Successful pings append the IP to ok.txt; failures append to no.txt.

Ping an arbitrary list of IPs

When targets span multiple subnets, place each IP on its own line in a file (e.g., ip.txt) and let the loop read the file:

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

The script processes every line, pings the address once, and records the result in the appropriate output file.

File locations

All generated files ( a.txt, ok.txt, no.txt) are created in the current command‑prompt working directory (e.g., C:\Windows\System32 if that is the prompt location). Move them as needed.

Network TroubleshootingpingIP scanningWindows cmdbatch ping
Linux Tech Enthusiast
Written by

Linux Tech Enthusiast

Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.