Troubleshooting with Ping

One important tool for troubleshooting networking is ping. To test if a device has proper networking, you can run ping on an IP address or a hostname. Once you are done, press CTRL+C (abbreviated ^C):

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=244 time=251.636 ms
64 bytes from icmp_seq=1 ttl=244 time=252.236 ms
64 bytes from icmp_seq=2 ttl=244 time=249.526 ms
64 bytes from icmp_seq=3 ttl=244 time=249.869 ms
64 bytes from icmp_seq=4 ttl=244 time=248.836 ms
64 bytes from icmp_seq=5 ttl=244 time=251.230 ms
64 bytes from icmp_seq=6 ttl=244 time=249.227 ms
64 bytes from icmp_seq=7 ttl=244 time=249.550 ms
--- ping statistics ---
8 packets transmitted, 8 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 248.836/250.264/252.236/1.174 ms

ping uses the Internet Control Message Protocol (ICMP) to test for problems. Here, we see it takes roughly 250 milliseconds for to reply to our messages. Of the 8 packets sent, all 8 were received, so we have 0 packet loss.

If you need to test out IPv6, then use the ping6 command. For both IPv4 and IPv6, you may find it helpful to bind to a specific IP address (send packets using a specific IP address). In that case, use the option -I. For example:

$ ping6 -I 1234:5678:abcd:ef::1

This will force ping6 to send and receive packets using the (fake) IPv6 address 1234:5678:abcd:ef::1.

Sometimes, you may see ping results that require further investigation:

--- ping statistics ---
2779223 packets transmitted, 2669400 packets received, 4.0% packet loss
round-trip min/avg/max/std-dev = 510.548/600.687/535545.801/958.211 ms

Here, our ping suffers 4% packet loss. This is quite high and should be investigated. Perhaps there is an issue with the hardware or the networking equipment is faulty. The average latency of 600ms is also very high. Ideally, when the client and server are on the same continent, latency should be under 100ms. A latency of around 200ms is average, and anything above 300ms is quite high and feels laggy.

If you get packet loss that is less than 100%, then some packets are still arriving. Networking is working somewhat, but there may be a misconfiguration somewhere, or faulty hardware. However, if you are getting 100% packet loss, then either your hardware is altogether broken, or your configuration is wrong.

You also should check your firewall. Because ping and ping6 both use ICMP, any firewall rules that block ICMP should be disabled. Be careful: rate-limiting ICMP may cause issues.