Command Line Tools

Ping Command Guide: Windows, Linux, and Mac Examples 2025

Master the ping command across all operating systems with real examples, advanced options, and troubleshooting techniques

Published September 9, 2025 • 10 minute read
🎯 Want to Test Without Command Line?

Try our web-based ping tool first to see results, then learn the command-line version

Test Ping Online First

Ping Command Basics

The ping command is one of the most fundamental network troubleshooting tools available on every operating system. It sends small packets to a target and measures how long it takes to get a response, helping you diagnose connectivity issues, measure latency, and verify network paths.

🚀 Quick Start for Impatient People
Windows:
ping google.com
Linux:
ping -c 4 google.com
Mac:
ping -c 4 google.com

Windows Ping Command

🪟 Windows Command Prompt

Basic Syntax
C:\> ping [options] hostname_or_ip
Essential Windows Ping Options
Option Description Example
-t Continuous ping (until stopped with Ctrl+C) ping -t google.com
-n count Number of ping packets to send ping -n 10 google.com
-l size Packet size in bytes (default 32) ping -l 1000 google.com
-w timeout Timeout in milliseconds ping -w 5000 google.com
-4 Force IPv4 ping -4 google.com
-6 Force IPv6 ping -6 google.com
Windows Ping Examples
1. Basic Ping (4 packets by default)
C:\> ping google.com Pinging google.com [142.250.191.78] with 32 bytes of data: Reply from 142.250.191.78: bytes=32 time=23ms TTL=117 Reply from 142.250.191.78: bytes=32 time=24ms TTL=117 Reply from 142.250.191.78: bytes=32 time=22ms TTL=117 Reply from 142.250.191.78: bytes=32 time=25ms TTL=117 Ping statistics for 142.250.191.78: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 22ms, Maximum = 25ms, Average = 23ms
2. Continuous Ping
C:\> ping -t google.com # Pings continuously until you press Ctrl+C
3. Large Packet Size Test
C:\> ping -l 1472 google.com # Tests with larger packets to check MTU
4. Multiple Pings with Custom Count
C:\> ping -n 20 google.com # Sends exactly 20 ping packets

Linux Ping Command

🐧 Linux Terminal

Basic Syntax
$ ping [options] hostname_or_ip
Key Difference: Linux ping runs continuously by default (like Windows -t). Use -c to specify count or Ctrl+C to stop.
Essential Linux Ping Options
Option Description Example
-c count Number of ping packets to send ping -c 5 google.com
-i interval Interval between packets (seconds) ping -i 2 google.com
-s size Packet size in bytes ping -s 1000 google.com
-W timeout Timeout in seconds ping -W 5 google.com
-f Flood ping (requires root) sudo ping -f google.com
-q Quiet mode (only summary) ping -q -c 10 google.com
-n No DNS resolution (numeric only) ping -n 8.8.8.8
Linux Ping Examples
1. Basic Ping with Count
$ ping -c 4 google.com PING google.com (142.250.191.78) 56(84) bytes of data. 64 bytes from lga25s62-in-f14.1e100.net (142.250.191.78): icmp_seq=1 time=23.2 ms 64 bytes from lga25s62-in-f14.1e100.net (142.250.191.78): icmp_seq=2 time=24.1 ms 64 bytes from lga25s62-in-f14.1e100.net (142.250.191.78): icmp_seq=3 time=22.8 ms 64 bytes from lga25s62-in-f14.1e100.net (142.250.191.78): icmp_seq=4 time=23.5 ms --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 22.815/23.400/24.134/0.504 ms
2. Quiet Mode with Statistics Only
$ ping -q -c 10 google.com PING google.com (142.250.191.78) 56(84) bytes of data. --- google.com ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 9013ms rtt min/avg/max/mdev = 22.234/23.891/25.123/0.891 ms
3. Custom Packet Size and Interval
$ ping -c 5 -s 1000 -i 2 google.com # 5 packets, 1000 bytes each, 2 second intervals
4. IPv6 Ping
$ ping6 google.com # Or: ping -6 google.com

Mac Ping Command

🍎 Mac Terminal

Mac ping is based on BSD Unix and is very similar to Linux, with a few differences in options and behavior.

Basic Syntax
$ ping [options] hostname_or_ip
Mac-Specific Ping Options
Option Description Mac Specific Notes
-c count Number of packets Same as Linux
-i interval Wait interval Minimum 1 second for non-root
-s packetsize Data bytes to send Default 56 bytes
-t timeout Timeout in seconds Different from Linux -W
-o Exit after first reply Mac-specific option
-D Print timestamps Mac-specific format
Mac Ping Examples
1. Basic Ping with Count
$ ping -c 4 google.com PING google.com (142.250.191.78): 56 data bytes 64 bytes from 142.250.191.78: icmp_seq=0 time=23.234 ms 64 bytes from 142.250.191.78: icmp_seq=1 time=24.123 ms 64 bytes from 142.250.191.78: icmp_seq=2 time=22.891 ms 64 bytes from 142.250.191.78: icmp_seq=3 time=23.567 ms --- google.com ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 22.891/23.454/24.123/0.456 ms
2. Single Ping (Exit After First Reply)
$ ping -o google.com PING google.com (142.250.191.78): 56 data bytes 64 bytes from 142.250.191.78: icmp_seq=0 time=23.234 ms --- google.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss
3. Ping with Timestamps
$ ping -D -c 3 google.com # Shows timestamps for each ping
Mac GUI Alternative: You can also use Network Utility (Applications > Utilities > Network Utility) for a graphical ping interface.

Cross-Platform Comparison

Feature Windows Linux Mac
Default Behavior 4 packets then stop Continuous until Ctrl+C Continuous until Ctrl+C
Count Option -n count -c count -c count
Packet Size -l size -s size -s size
Timeout -w milliseconds -W seconds -t seconds
Continuous -t Default behavior Default behavior
IPv6 -6 ping6 or -6 ping6
Flood Ping Not available -f (root only) -f (root only)

Advanced Ping Techniques

🚀 Pro Tip: Universal Ping Commands That Work Everywhere

These commands work consistently across all platforms:

# Basic connectivity test (adjust count option per platform) Windows: ping google.com Linux/Mac: ping -c 4 google.com # Test specific IP (no DNS lookup needed) ping 8.8.8.8 # Test with larger packets (MTU discovery) Windows: ping -l 1472 google.com Linux/Mac: ping -s 1472 -c 4 google.com

1. Network Discovery with Ping Sweeps

Windows (PowerShell)
PS> 1..254 | ForEach-Object { ping -n 1 192.168.1.$_ | Select-String "Reply" }
Linux/Mac (Bash)
$ for i in {1..254}; do ping -c1 192.168.1.$i | grep "64 bytes" done

2. Monitoring Network Quality

Continuous Monitoring with Statistics
# Windows - Log ping results ping -t google.com > ping_log.txt # Linux - Statistical summary every 10 pings ping -c 100 google.com | awk '/transmitted/ {print $0}' # Mac - Timestamped continuous monitoring ping -D google.com | tee ping_results.log

3. MTU Path Discovery

# Find maximum MTU size (start high and work down) Windows: ping -f -l 1472 google.com Linux: ping -M do -s 1472 -c 1 google.com Mac: ping -D -s 1472 -c 1 google.com # If this fails, try smaller sizes: 1200, 1000, 800, etc.

4. Testing Different Protocols and Servers

# Test IPv4 vs IPv6 performance ping google.com # Usually IPv4 ping6 google.com # Force IPv6 (Linux/Mac) ping -6 google.com # Force IPv6 (Windows) # Test multiple DNS servers ping 8.8.8.8 # Google DNS ping 1.1.1.1 # Cloudflare DNS ping 208.67.222.222 # OpenDNS

Interpreting Ping Results

✅ Good Ping Results
  • Low latency: Under 50ms for most activities
  • Consistent times: Little variation between pings
  • No packet loss: 0% loss indicates stable connection
  • Reasonable TTL: Shows reasonable hop count
⚠️ Problematic Results
  • High latency: Over 100ms for local services
  • Variable times: Large differences between pings
  • Packet loss: Any percentage indicates problems
  • "Request timed out": Network or firewall issues
Common Error Messages
Error Message Likely Cause What to Check
"Request timed out" Firewall blocking or destination down Firewall settings, target server status
"Destination host unreachable" Routing problem Network configuration, routing tables
"Could not find host" DNS resolution failure DNS settings, hostname spelling
"Network is unreachable" No route to destination Default gateway, network connectivity
"TTL expired in transit" Too many hops or routing loop Routing configuration, use traceroute

Ping Troubleshooting Workflow

🔧 Systematic Troubleshooting Steps
  1. Test localhost: ping 127.0.0.1 (tests TCP/IP stack)
  2. Test default gateway: ping [gateway IP] (tests local network)
  3. Test external IP: ping 8.8.8.8 (tests internet connectivity)
  4. Test external hostname: ping google.com (tests DNS resolution)
  5. Test target specifically: ping [your target]
Quick Diagnostic Commands
# Quick connectivity test battery ping 127.0.0.1 # Local computer ping 192.168.1.1 # Typical home router ping 8.8.8.8 # Google DNS (reliable external) ping google.com # Test DNS + connectivity # If any of these fail, you know where the problem is

Compare with Web-Based Testing

Use our online ping tool to compare results with your command-line testing

Test Ping Online

Master More Network Tools

What is Ping? Basics

New to ping? Start with our beginner-friendly explanation of what ping actually measures.

Beginner
Complete Ping Testing Guide

Advanced ping testing techniques and result interpretation for network optimization.

Advanced