Seven Essential Uses of the Ping Command
This article explains seven practical uses of the ping command, covering basic connectivity checks, continuous ping with -t, hostname resolution with -a, custom packet counts with -n, large packet sizes with -l, route tracing with -r, and batch pinging an IP range, each illustrated with concrete examples and output details.
Ping basic usage
Ping is a TCP/IP utility used to test connectivity, measure latency, resolve domain names to IP addresses, and infer the remote operating system from the TTL value. The output shows bytes (packet size), time (response latency) and TTL (time‑to‑live).
Default TTL values: Linux 64 or 255, Windows NT/2000/XP 128, Windows 98 32, UNIX hosts 255. Approximate ranges: 100‑130 → Windows, 240‑255 → UNIX/Linux.
Continuous ping ( ping -t )
The -t switch sends packets continuously until interrupted with Ctrl+C. After interruption the utility prints the total number of packets sent, received and lost, confirming link stability.
Resolve hostname ( ping -a )
The -a switch resolves the target IP address to its NetBIOS or DNS hostname, displaying the remote machine’s name.
Specify packet count ( ping -n )
By default four packets are sent. Using -n the count can be set explicitly. Example: ping -n 10 47.93.187.142 The command returned 10 replies, no loss, fastest 32 ms, slowest 55 ms, average 37 ms, indicating a healthy connection. In a congested network packet loss would appear in the summary.
Custom packet size ( ping -l size )
The -l option sets the payload size. Windows defaults to 32 bytes and allows up to 65 500 bytes; sending a packet of 65 500 bytes can crash the target, so Microsoft caps the value. Combined with -t it can be used for a denial‑of‑service attack, e.g. ping -l 65500 -t 211.84.7.46 This continuously floods the target with maximum‑size packets until interrupted.
Record route ( ping -r count )
The -r switch records the route of up to nine hops. Example: ping -n 1 -r 9 202.102.224.25 The single packet returns the IP addresses of up to nine intermediate routers.
Batch ping an IP subnet
For a /24 subnet the following command pings every address from .1 to .255: for /L %D in (1,1,255) do ping 10.168.1.%D The tuple (1,1,255) means start at 1, increment by 1, stop at 255, covering the entire range. Replace the base address with the desired subnet.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
