The ping Command

"Is the server up?" - Ping is your first diagnostic tool.

Basic Ping

Terminal
$ping google.com
PING google.com (142.250.185.78): 56 data bytes 64 bytes from 142.250.185.78: icmp_seq=0 ttl=117 time=14.2 ms 64 bytes from 142.250.185.78: icmp_seq=1 ttl=117 time=13.8 ms ^C --- google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms

Press Ctrl+C to stop.

Understanding the Output

FieldMeaning
64 bytesResponse size
icmp_seqPacket sequence number
ttlTime To Live (hops remaining)
timeRound-trip time (latency)
packet lossPercentage lost

What's Good Latency?

  • Under 50ms: Excellent
  • 50-100ms: Good
  • 100-200ms: Okay
  • Over 200ms: Slow

Depends on distance. Same datacenter: under 1ms. Across continents: 100-200ms.

Limited Ping Count

Terminal
$ping -c 4 google.com
(sends 4 packets then stops)

-c 4 = count of 4 packets. No need to Ctrl+C.

Ping an IP Directly

Terminal
$ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: icmp_seq=0 ttl=118 time=12.1 ms ...

This bypasses DNS. Useful for diagnosing: is it network or DNS?

Diagnosing Issues

No Response

Terminal
$ping -c 3 10.0.0.99
PING 10.0.0.99 (10.0.0.99): 56 data bytes --- 10.0.0.99 ping statistics --- 3 packets transmitted, 0 received, 100% packet loss

100% loss means: host is down, unreachable, or blocking ICMP.

High Latency

Terminal
$ping -c 3 server
64 bytes: icmp_seq=0 ttl=64 time=450.2 ms 64 bytes: icmp_seq=1 ttl=64 time=523.1 ms

Consistently high latency = network congestion or distant server.

Packet Loss

Terminal
$ping -c 10 server
10 packets transmitted, 7 received, 30% packet loss

30% loss = network problems. Investigate the path.

Quick Network Check

Terminal
$# Can I reach the internet?
$ping -c 2 8.8.8.8
$
$# Is DNS working?
$ping -c 2 google.com
$
$# Can I reach my gateway?
$ping -c 2 $(ip route | grep default | awk '{print $3}')

Troubleshooting Order

  1. Ping gateway (local network)
  2. Ping 8.8.8.8 (internet, skip DNS)
  3. Ping google.com (DNS + internet)

If 1 fails: local network issue. If 2 fails but 1 works: routing/firewall issue. If 3 fails but 2 works: DNS issue.

Knowledge Check

You can ping 8.8.8.8 but not google.com. What's the likely problem?

Quick Reference

CommandPurpose
ping hostContinuous ping (Ctrl+C to stop)
ping -c 4 hostSend 4 packets
ping 8.8.8.8Test internet (skip DNS)
ping gatewayTest local network

Key Takeaways

  • ping tests if a host is reachable
  • Use -c N for limited packet count
  • Check latency (time) and packet loss
  • Ping IP directly to bypass DNS
  • 100% loss = down or blocking ICMP

Next: DNS troubleshooting.