Fundamentals 9 min read

Mastering Ping: From Basic Usage to Advanced Options and Bulk Scanning

Learn how to use the Ping command for network troubleshooting, covering basic syntax, interpreting results such as RTT and TTL, advanced flags like -t, -a, -n, -l, -r, and techniques for batch pinging multiple IPs and logging outcomes.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Ping: From Basic Usage to Advanced Options and Bulk Scanning

Ping (Packet Internet Groper) is a fundamental command‑line tool for testing network connectivity.

It can verify whether a computer can communicate with another host or network device.

Part 1: Basic Usage of Ping

What is Ping?

Ping sends ICMP echo‑request packets to a target and waits for echo‑reply packets, similar to sonar detecting an object by sound.

How to Use Ping

Open a command prompt (Windows) or terminal (Linux/macOS) and type: ping [target host or IP address] Example – ping Google’s public DNS (8.8.8.8):

ping 8.8.8.8

Interpreting Basic Results

Typical output includes:

Target IP address

Number of bytes sent

Round‑trip time (RTT) or response time

TTL (Time To Live) value

Bytes Sent

By default each ICMP packet carries 32 bytes of data, though this can be changed with advanced options.

RTT (Round‑Trip Time)

Measured in milliseconds; lower RTT indicates a faster connection, higher RTT suggests latency.

TTL Value

TTL is an 8‑bit field that limits the maximum number of hops a packet can traverse. Each router decrements TTL by one; when it reaches zero the packet is discarded. TTL can hint at the remote OS: values around 100‑130 often indicate Windows, while 240‑255 suggest UNIX/Linux.

Example Scenario

Problem: Unable to access the Internet; need to verify communication with the default gateway.

Solution: Run: ping [default‑gateway‑IP] If the ping succeeds, the computer can reach the router; otherwise, check the network connection or router settings.

Part 2: Advanced Ping Options

1. -t – Continuous Ping

Ping the target continuously until manually stopped, useful for monitoring stability.

ping -t [target host or IP]

2. -a – Resolve Hostname

Attempts to resolve the target’s IP address to its hostname.

ping -a [target host or IP]

3. -n – Specify Number of Echo Requests

By default Ping sends four packets; use -n to set a custom count.

ping -n [count] [target host or IP]

4. -l – Set Packet Size

Change the size of the ICMP payload (default 32 bytes). Large sizes may cause issues.

ping -l [size] [target host or IP]

5. -r – Record Route

Records the route taken by the packets, showing each router traversed.

ping -r [count] [target host or IP]

Part 3: Batch Ping Multiple IP Addresses

1. Ping an Entire Subnet

Use a loop to ping every address in a range, e.g., 192.168.1.1‑255:

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

2. Ping Addresses from a Text File

Store IPs in ip.txt and loop through them:

for /F %D in (ip.txt) do ping %D

3. Record Results

Append each ping’s output to results.txt for later analysis:

for /F %D in (ip.txt) do (ping %D >> results.txt)

4. Separate Success and Failure

Save successful pings to success.txt and failures to failure.txt:

for /F %D in (ip.txt) do (ping %D -n 1 && echo %D>>success.txt || echo %D>>failure.txt)

Conclusion

Ping is a powerful tool for testing connectivity, measuring latency, and identifying devices on a network. Understanding its basic usage, advanced options, and batch techniques enables both administrators and regular users to diagnose and manage network issues effectively.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Network TroubleshootingpingCommand Linebatch scriptingAdvanced Options
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.