ping sends ICMP echo requests to a host and prints the echo replies, along with round-trip time. It is the simplest tool for answering "is this host reachable?" and the first command anyone reaches for when troubleshooting a network problem. Its name comes from the sonar "ping" that bounces off an object and returns.
ping example.com # ping forever, Ctrl+C to stop
ping -c 4 example.com # 4 pings and stop
ping -i 0.2 host # fast interval (root)
ping -s 1400 host # large packets
ping6 ::1 # IPv6 ping
A successful ping proves that the target is up, that ICMP is allowed through any firewalls, and that routing works in both directions. A failed ping could mean anything from a down host to a firewall dropping ICMP (a common but annoying practice), which is why ping failure should never be taken as definitive evidence that a machine is offline.
On Linux, modern ping uses the CAP_NET_RAW capability rather than being setuid-root. The -M do flag combined with -s lets you probe the path MTU by sending packets with the Don't Fragment bit set—an old trick still occasionally useful for diagnosing tunneling or VPN issues.
Related terms: traceroute
Discussed in:
- Chapter 12: Networking — ping: Is It Alive?
Also defined in: Textbook of Linux