How-to

The ping Command, Used Properly

ping sends ICMP echo requests and times the replies. With the right flags it measures latency, loss, jitter and path MTU, all from one familiar tool.

What does ping tell me?

Whether a host answers ICMP echo, and how long the round trip takes. The summary at the end adds packet loss and the minimum, average, maximum and mean deviation of round-trip times. A host that does not answer is not necessarily down: many networks filter ICMP. A host that answers is reachable at the IP level, which rules out a whole class of problems at once.

Which everyday forms should I know?

ping -c 5 198.51.100.12            # five packets, then stop
ping -c 20 -i 0.2 198.51.100.12    # faster interval for a quick sample
ping -w 30 198.51.100.12           # run for 30 seconds total
ping -4 -c 3 updates.example.org   # force IPv4 for a name

Without -c or -w, Linux ping runs until you press Ctrl+C. Intervals below 0.2 seconds require root. Since our machines are IPv4 only, -4 avoids confusing errors when a name also has IPv6 records.

How do I read the summary?

--- 198.51.100.12 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 3805ms
rtt min/avg/max/mdev = 71.802/72.115/73.410/0.388 ms
ValueWhat it says
minBest case; mostly set by distance
avgTypical latency
maxWorst spike in the sample
mdevJitter; low values mean stable timing
lossShare of packets without reply

The minimum is the most honest measure of path length, because it excludes queueing. Light in fiber covers roughly 200 km per millisecond one way, so distance sets a floor no network can beat; the Latency entry turns that into estimates between our six cities.

How do I test the path MTU?

Send packets that must not be fragmented and step the size:

ping -M do -s 1472 -c 3 198.51.100.12     # 1472 + 28 header bytes = 1500
ping -M do -s 1392 -c 3 198.51.100.12     # 1420 total, typical inside a WireGuard tunnel

"Message too long" or silent loss at 1472 while smaller sizes pass means something on the path has a smaller MTU. That causes the strange symptom where small requests work and large transfers stall. tracepath finds the exact hop automatically; see tracepath vs traceroute.

Can I keep a timestamped ping log?

ping -D -i 5 198.51.100.12 | tee -a /var/log/ping-replica.log

-D prefixes each line with a Unix timestamp, so you can match a loss burst to the time a user complained. For long-term graphs, tools such as SmokePing or a monitoring agent do the same continuously.

What about flood ping?

ping -f, root only, sends packets as fast as replies come back and prints a dot per lost packet. It is a quick stress test of a link you own, for example between two of your machines. Never flood hosts you do not control; it looks like an attack and may be filtered or reported. On your own links, a short run such as ping -f -c 10000 reveals loss that a slow ping would miss.

Why does ping fail when the service works?

  • The target or a firewall on the way drops ICMP echo. Test the real port instead: nc -vz host 443.
  • Your own firewall blocks outbound or inbound ICMP. Allow echo-reply in nftables or firewalld.
  • Rate limiting: many routers answer only a few pings per second, so fast intervals show false loss.

Keep ICMP echo allowed on your own machines. It costs nothing and makes troubleshooting much easier for you and for anyone helping you.

How do I compare cities before ordering?

Ping a host you know in each region from where your users are. Lower minimum RTT means a better location for them. Prices are identical in Phoenix, Ashburn, Chicago, Seattle, Amsterdam and Singapore, so latency to your audience is the only factor that should decide.

Keep Reading

tracepath vs traceroute

Two ways to trace a network path: traceroute with its UDP, ICMP and TCP modes, tracepath with MTU discovery and no root, plus mtr for loss.

Open

Latency

Why distance sets the floor for ping time, how to estimate round trips between our six cities and how to choose a location.

Open

The ip command

Read addresses, links, routes and neighbors with ip, understand the /31 setup on our machines and make test changes without losing SSH.

Open

Servers in Singapore

Southeast Asia hub with routes to Indonesia, Malaysia, India and Australia, including 5 TB of outgoing traffic a month.

Open

FAQ

Quick Answers

Use ping -c followed by the count, for example ping -c 5.

Mean deviation of round-trip times, a measure of jitter.

Use ping -M do -s with a payload size; 1472 bytes plus 28 header bytes equals a 1500 byte packet.

ICMP is filtered somewhere. Test the service port with nc or curl instead.

The machines are IPv4 only, so use ping -4 or IPv4 addresses.