How To Ping In Linux

How To Ping In Linux

Reading time1 min
#Networking#Linux#NetworkDiagnostics#Ping#Sysadmin

Mastering Advanced Ping Techniques in Linux for Reliable Network Diagnostics

When it comes to network troubleshooting, the humble ping command is usually the first tool that comes to mind. Most users associate ping with a simple up-or-down check—does a host respond or not? But if you stop at this basic usage, you’re missing out on the real power of ping in Linux. Advanced ping options can give you deep insights into latency patterns, packet loss, jitter, and even network congestion—all critical factors that standard ping tests might overlook.

In this post, I’ll walk you through advanced Linux ping techniques that will revolutionize how you diagnose network issues. Whether you're a sysadmin, network engineer, or enthusiast, mastering these will save you hours troubleshooting elusive and complex connectivity problems.


Why Go Beyond Basic Ping?

The default ping output looks something like this:

ping google.com

Output snippet:

64 bytes from iad23s63-in-f14.1e100.net (172.217.3.110): icmp_seq=1 ttl=56 time=12.3 ms
64 bytes from iad23s63-in-f14.1e100.net (172.217.3.110): icmp_seq=2 ttl=56 time=13.5 ms

Useful? Yes.

Insightful? Not always.

What if packets are occasionally lost? What if latency spikes intermittently? What about monitoring over an extended period? Basic ping doesn’t reveal these details effectively.


Advanced Ping Techniques You Should Know

1. Continuous Ping with Interval Control

By default, Linux’s ping sends one packet per second until you stop it with CTRL+C.

To change the interval between pings:

ping -i 0.2 google.com

This sets the interval to 0.2 seconds (default minimum is 0.2 unless you’re running as root). This faster rate helps identify short bursts of packet loss or jitter that may disappear at slower intervals.

2. Limiting Number of Pings

For controlled testing, use the -c option to specify how many pings to send:

ping -c 10 google.com

Sends exactly 10 packets then stops automatically.

3. Setting Packet Size

You can mimic transmission of larger payloads that might be dropped or fragmented by the network using -s:

ping -c 5 -s 1200 google.com

This sends five pings with a data size of 1200 bytes rather than the default 56 bytes (plus headers).

Why is this useful? Some networks have MTU or fragmentation issues not revealed by small pings.

4. Flood Ping (Root Only)

If you want rapid-fire packets to stress test a connection or measure packet loss under load:

sudo ping -f google.com

Flood ping sends packets as fast as possible; observe results carefully since it can be disruptive on your network and target host.

5. Record Route Option (Linux variant)

You can append route information using the -R flag:

ping -R google.com

This adds routing record data inside each reply ICMP packet to help you trace the exact route your packets take—useful for spotting routing loops or unexpected hops.

Note: Route recording isn’t supported by all routers.

6. Timestamp Option

Using -T allows MD5 timestamps for each ICMP echo request/reply pair—great when analyzing time discrepancies across different networking equipment (requires compatible routers/devices):

ping -T tsonly google.com

7. Adaptive Ping with Dead Timeouts

If your target host only responds intermittently or goes down periodically, use -w to specify a timeout for total execution and -W for per-packet timeout:

ping -w 20 -W 3 -c 10 google.com

Here, the entire ping operation times out after 20 seconds; each packet waits up to 3 seconds for a reply before moving on to the next.

8. Verbose and Numeric Output Options

Verbose mode (-v) reveals more detailed info useful when debugging packets; numeric mode (-n) stops name resolution (speeding up output if DNS is slow):

ping -v -n google.com

Practical Examples for Real-world Network Diagnosis

Diagnosing Intermittent Packet Loss Over Time

You suspect your connection sometimes drops packets but aren’t sure when or how often.

Try:

ping -i 0.5 -c 100 google.com > ping-log.txt

This pings every half-second for 100 packets and saves results in a file for later analysis. Check for any “Request timed out” lines or spikes in latency (time= values).


Testing MTU Issues Causing Fragmentation

Some applications fail due to dropped large packets on VPNs or certain ISPs.

Use a large packet size without fragmentation allowed via -M do option:

ping -M do -s 1472 google.com

Here, 1472 + 28 bytes ICMP/IP header =1500 MTU. If this fails but smaller sizes succeed, you likely have an MTU problem requiring adjustment.


Stress Testing Your Network Link

To check stability under heavy load:

sudo ping -f -i 0.05 google.com

Flood ping with very short intervals can reveal issues only apparent under heavy load, like buffer overflows causing packet loss or delayed responses.


Summary: Use Ping Like a Pro!

Mastering these advanced options turns ping from a simple connectivity check into a powerful diagnostic instrument that provides actionable insights into network behavior beyond “reachable?” vs “unreachable?”

Key takeaways:

  • Adjust intervals (-i) and counts (-c) for precise control.
  • Tailor packet size (-s) and leverage MTU tests (-M do) to diagnose complex transfer issues.
  • Use flood mode cautiously when stress testing.
  • Capture routing data (-R) and timestamps (-T) for deeper visibility.
  • Timeout controls (-w, -W) help adapt tests for unstable hosts.

Give these techniques a spin next time your network isn’t playing nice—you might just unearth hidden issues without firing up expensive tools or complex scripts!


If you found this post helpful and want more practical Linux networking tips, subscribe and stay tuned! Got any tricky network problems you solved with fancy pings? Drop your experience in the comments below!