Skip to content

Ping command guide: Windows, Linux & Mac

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

TL;DR
Run ping google.com on any OS to test your connection. On Windows it sends 4 packets by default; on Linux/Mac it runs until you press Ctrl+C. Use ping -c 10 8.8.8.8 for a 10-packet test. Want the no-install version? Try our web ping tool.

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 the impatient:

  • Windows: ping google.com
  • Linux: ping -c 4 google.com
  • Mac: ping -c 4 google.com

Windows ping command

Basic syntax:

ping [options] hostname_or_ip

Essential Windows ping options

OptionDescriptionExample
-tContinuous ping (until stopped with Ctrl+C)ping -t google.com
-n countNumber of ping packets to sendping -n 10 google.com
-l sizePacket size in bytes (default 32)ping -l 1000 google.com
-w timeoutTimeout in millisecondsping -w 5000 google.com
-4Force IPv4ping -4 google.com
-6Force IPv6ping -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:

ping -t google.com    # Pings continuously until Ctrl+C

3. Large packet size test:

ping -l 1472 google.com    # Tests with larger packets to check MTU

4. Multiple pings with custom count:

ping -n 20 google.com    # Sends exactly 20 ping packets

Linux ping command

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

OptionDescriptionExample
-c countNumber of ping packets to sendping -c 5 google.com
-i intervalInterval between packets (seconds)ping -i 2 google.com
-s sizePacket size in bytesping -s 1000 google.com
-W timeoutTimeout in secondsping -W 5 google.com
-fFlood ping (requires root)sudo ping -f google.com
-qQuiet mode (only summary)ping -q -c 10 google.com
-nNo 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

3. Custom packet size and interval:

ping -c 5 -s 1000 -i 2 google.com    # 5 packets, 1000 bytes, 2s intervals

4. IPv6 ping:

ping6 google.com         # or: ping -6 google.com

Mac ping command

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

Mac-specific ping options

OptionDescriptionMac-specific notes
-c countNumber of packetsSame as Linux
-i intervalWait intervalMinimum 1 second for non-root
-s packetsizeData bytes to sendDefault 56 bytes
-t timeoutTimeout in secondsDifferent from Linux -W
-oExit after first replyMac-specific option
-DPrint timestampsMac-specific format

Mac ping examples

$ 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

Single ping (exit after first reply):

ping -o google.com

Ping with timestamps:

ping -D -c 3 google.com

Mac GUI alternative: you can also use Network Utility (Applications > Utilities > Network Utility) for a graphical ping interface.

Cross-platform comparison

FeatureWindowsLinuxMac
Default behaviour4 packets then stopContinuous until Ctrl+CContinuous until Ctrl+C
Count option-n count-c count-c count
Packet size-l size-s size-s size
Timeout-w ms-W seconds-t seconds
Continuous-tdefaultdefault
IPv6-6ping6 or -6ping6
Flood pingNot available-f (root)-f (root)

Advanced ping techniques

Universal ping commands that work everywhere

# 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

Network discovery with ping sweeps

Windows (PowerShell):

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

Monitoring network quality

# Windows — log ping results
ping -t google.com > ping_log.txt

# Linux — statistical summary
ping -c 100 google.com | awk '/transmitted/ {print $0}'

# Mac — timestamped continuous monitoring
ping -D google.com | tee ping_results.log

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.

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 messageLikely causeWhat to check
"Request timed out"Firewall blocking or destination downFirewall settings, target server status
"Destination host unreachable"Routing problemNetwork configuration, routing tables
"Could not find host"DNS resolution failureDNS settings, hostname spelling
"Network is unreachable"No route to destinationDefault gateway, network connectivity
"TTL expired in transit"Too many hops or routing loopRouting 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].

If any of these fail, you know exactly where the problem is. Compare against our web-based ping tool running from a different network — if our tool can reach your target but you can't, the issue is on your side.

Related reading: What is ping? · Complete ping testing guide · Network diagnostics — professional troubleshooting