Frequently Asked Question

How does ping work, and why does it sometimes lie about whether a host is up?

ping sends ICMP echo-request packets to a host and times how long the matching echo-reply takes to return. A successful ping verifies four things at once: DNS resolution worked, the IP network path is open in both directions, the remote host is up enough to handle ICMP, and you have a measurement of round-trip time. Linux ping runs until you hit Ctrl+C; use -c 4 to send a fixed number of packets and -i 0.2 to send them faster than the default one per second.

Many firewalls block or rate-limit ICMP, especially on public-facing servers and cloud instances, because echo replies historically helped attackers map networks. A failing ping therefore does not necessarily mean a host is down, it might just mean its administrator dropped ICMP. The reverse is also true: a successful ping doesn't guarantee the service you actually care about (HTTP, SSH, the database) is responding. Use curl, ssh, or nc -zv host port to test the actual service.

Further reading and video