How to Test Network Connectivity with ping
The ping command tests whether a host is reachable over the network. ping google.com sends small probes and reports how fast replies come back. It is the first tool to use when a website, server or printer is not responding.
Ping a host
ping keeps going until you stop it with Ctrl+C, then prints a summary with packet loss and average time. The time shown is the round-trip latency in milliseconds.
Limit the count with -c
For scripts and quick checks, send a fixed number of probes with -c. Four is enough to see if a host answers.
Set the interval with -i
Default intervals are 1 second. Use -i to send probes faster or slower, which matters when testing a flaky link without flooding it.
Ping by IP to skip DNS
Ping a raw IP to test pure network reachability without DNS: ping 8.8.8.8. If an IP answers but the hostname does not, the problem is DNS, not the network.
Interpret the results
100% packet loss with timeouts means the host is unreachable or blocks ICMP (many firewalls do). High and rising times point to congestion. See ping for all options, and check your own addresses with ip addr.
Keep learning
Related guides: How to Manage Network Interfaces with the Linux ip Command · How to Query DNS with dig and nslookup · How to Check Open Ports with ss and netstat. Read all tutorials on the Learn Linux blog.