1. Library
  2. Tools and Commands
  3. Connectivity Testing

Updated 10 hours ago

The basic ping command is a blunt instrument. It sends tiny packets, waits patiently, and tells you whether something got through. But networks fail in subtle ways that basic ping never reveals.

The flags and options transform ping from a simple yes/no test into a diagnostic tool that can expose packet loss patterns, MTU problems, routing inefficiencies, and intermittent failures. Here's how to use them.

The Problem with Default Ping

Default ping sends small packets (56-64 bytes) at leisurely one-second intervals. This is forgiving—too forgiving. A network can successfully ping while dropping 20% of real traffic, fragmenting large packets, or routing through congested paths.

The options below let you stress-test what actually matters.

Controlling How Many Packets

PlatformFlagExample
Linux/macOS-c countping -c 10 example.com
Windows-n countping -n 10 example.com

Linux and macOS ping forever by default. Windows sends exactly 4 packets.

When to adjust: 4 packets catch nothing. 10-20 packets reveal trends. 100+ packets expose intermittent problems—that 2% packet loss that makes video calls stutter but doesn't show up in a quick test.

Windows users: add -t to ping continuously like Linux/macOS. Press Ctrl+C to stop and see statistics.

Testing with Realistic Packet Sizes

PlatformFlagExample
Linux/macOS-s sizeping -s 1000 example.com
Windows-l sizeping -l 1000 example.com

The default ping lies to you. Small packets succeed even when your network is broken for real traffic.

The Internet's standard MTU (Maximum Transmission Unit) is 1500 bytes. Packets larger than the path MTU get fragmented—split into pieces that must all arrive and be reassembled. If any piece is lost, the whole packet fails.

# Test near the MTU limit (1472 data + 28 headers = 1500 total)
ping -s 1472 example.com

If large packets fail but small ones succeed, you've found an MTU or fragmentation problem. This is common with VPNs, tunnels, and certain ISP configurations.

Finding Your Path MTU

Combine large packets with the Don't Fragment flag to discover your exact path MTU:

PlatformFlagExample
Linux/macOS-Dping -D -s 1472 example.com
Windows-fping -f -l 1472 example.com

This tells routers: "Don't fragment this packet. If it's too big, drop it and tell me."

Path MTU discovery is detective work:

# Start at standard MTU minus headers
ping -D -s 1472 example.com    # If this fails...
ping -D -s 1400 example.com    # Try smaller...
ping -D -s 1300 example.com    # Keep going until success

The largest size that works is your path MTU (minus the 28-byte header). This number matters for VPN configuration, tunnel setup, and diagnosing "large file transfers fail but small ones work" mysteries.

Adjusting Timing

Interval between packets (Linux/macOS only):

ping -i 0.5 example.com   # Send every 0.5 seconds (faster)
ping -i 5 example.com     # Send every 5 seconds (slower)

Intervals below 0.2 seconds require root privileges—this prevents accidental (or intentional) ping floods.

Timeout waiting for replies:

PlatformFlagUnitExample
Linux/macOS-Wsecondsping -W 2 example.com
Windows-wmillisecondsping -w 2000 example.com

Shorter timeouts fail faster when hosts are unreachable. Longer timeouts accommodate slow satellite links or overloaded servers.

Setting TTL (Time to Live)

PlatformFlagExample
Linux/macOS-t ttlping -t 10 example.com
Windows-i ttlping -i 10 example.com

TTL limits how many routers a packet can traverse. Each hop decrements the counter; when it hits zero, the packet dies and the router sends back "Time to live exceeded."

Low TTL values reveal routing behavior:

ping -t 5 example.com   # Will it reach in 5 hops?

If you get TTL exceeded messages from unexpected routers, packets may be taking inefficient routes or hitting routing loops.

Quiet Mode for Scripts

ping -q -c 100 example.com

Quiet mode (-q) suppresses per-packet output, showing only the final statistics. Perfect for automation:

#!/bin/bash
if ping -c 1 -W 1 example.com > /dev/null 2>&1; then
    echo "Host is up"
else
    echo "Host is down"
fi

Or for periodic monitoring:

#!/bin/bash
while true; do
    echo "$(date): $(ping -c 100 -q example.com | grep 'packet loss')"
    sleep 60
done

Flood Ping (Requires Root)

sudo ping -f example.com

Flood ping sends packets as fast as the network can handle them. It displays a dot for each packet sent and erases one for each reply—a visual representation of packet loss.

This is essentially a weapon. It can saturate network links, overwhelm hosts, and trigger security alerts. Only use it on networks you own, for legitimate stress testing, with full awareness of the consequences.

Choosing a Network Interface

On multi-homed systems (multiple network interfaces):

ping -I eth0 example.com    # Use wired connection
ping -I wlan0 example.com   # Use wireless

This isolates which path you're testing—essential when comparing wired vs. wireless performance or diagnosing issues with specific interfaces.

IPv4 vs. IPv6

ping -4 example.com   # Force IPv4
ping -6 example.com   # Force IPv6

On Linux/macOS, you can also use ping6 for IPv6. Windows auto-detects but respects the -4 and -6 flags.

Explicitly choosing IP versions diagnoses whether problems are protocol-specific. "Works on IPv4, fails on IPv6" points to different infrastructure or configuration issues.

Practical Combinations

Quick connectivity check:

ping -c 1 -W 1 example.com

Quality assessment (catches intermittent issues):

ping -c 100 example.com

Path MTU discovery:

ping -D -s 1472 example.com   # Reduce size until it works

Stress test (with permission):

sudo ping -c 100 -i 0.2 example.com

Long-term monitoring:

ping -q -c 1000 example.com

Platform-Specific Extras

Linux:

  • -A: Adaptive ping—adjusts interval based on round-trip time
  • -R: Record route—shows up to 9 hops in the packet's path

macOS:

  • -a: Audible ping—beeps for each reply
  • -o: Exit after first successful reply

Windows:

  • -r count: Record route for specified hops
  • -s count: Add timestamps for specified hops

Frequently Asked Questions About Ping Options

Was this page helpful?

😔
🤨
😃