ping
Test network connectivity, measure round-trip latency, and detect packet loss by sending ICMP echo requests with the ping command.
- What ping Does and When to Use It
- Core Concepts of ping
- ICMP Protocol and ping
- Ping Packet Loss and Network Quality
- Ping Round-Trip Time (RTT) and Latency
- Common Tasks with ping
- How to Ping a Host with a Limited Packet Count
- How to Ping an IP Address to Bypass DNS
- ping Troubleshooting
- Related Tools and Guides
ping is a network diagnostic command that tests host reachability, measures round-trip latency, and detects packet loss by sending ICMP echo request packets on Linux, macOS, and Windows.
What ping Does and When to Use It
The ping command sends Internet Control Message Protocol (ICMP) echo request packets to a target host and waits for ICMP echo reply packets. Each reply includes the round-trip time (RTT) in milliseconds, the Time to Live (TTL) value, and the ICMP sequence number. After completing, ping prints a summary with minimum, average, and maximum RTT along with the packet loss percentage.
The ping command is the first tool to reach for when diagnosing network connectivity issues. It answers the fundamental question: "Can my machine reach this host?" Use ping to confirm whether a server is online, measure baseline latency to a remote host, and detect intermittent packet loss on a network path.
The ping command cannot determine wherea connectivity failure occurs along the network path. If ping fails, the problem could be at the destination host, at a router in the middle, at the local gateway, or at the local firewall. Use the traceroute commandto identify the specific hop where packets fail. For a detailed comparison, see ping vs traceroute: when to use which.
Core Concepts of ping
ICMP Protocol and ping
The ping command uses ICMP (Internet Control Message Protocol), a network-layer protocol separate from TCP and UDP. ICMP echo requests and replies do not use port numbers — they operate at the IP layer. Many firewalls and cloud security groups block ICMP traffic by default, which means a host can be fully operational and reachable on TCP ports (HTTP, SSH) while appearing unreachable to ping.
Ping Packet Loss and Network Quality
The ping command reports packet loss as a percentage of sent packets that received no reply. A result of 0% packet loss indicates a stable connection. Packet loss between 1% and 5% suggests network congestion or an unreliable link. Packet loss above 10% indicates a significant network problem that affects application performance. A result of 100% packet loss means either the host is down, ICMP is blocked, or a routing failure prevents packets from reaching the destination.
Ping Round-Trip Time (RTT) and Latency
The ping command measures round-trip time in milliseconds — the total time for a packet to travel from the source to the destination and back. RTT below 50 ms is typical for hosts on the same continent. RTT between 100–200 ms is expected for intercontinental connections. RTT above 300 ms degrades real-time applications like VoIP and video conferencing.
Common Tasks with ping
How to Ping a Host with a Limited Packet Count
Send exactly 5 ICMP echo requests and stop:
ping -c 5 example.comOn Windows, the equivalent flag is
-n:
ping -n 5 example.com.
How to Ping an IP Address to Bypass DNS
Test raw network connectivity without DNS resolution:
ping -c 3 8.8.8.8If this succeeds but
ping example.com fails, the issue is DNS resolution, not network connectivity. Use the
host commandor the
dig commandto diagnose DNS.
For detailed usage, see How to test network connectivity with ping.
ping Troubleshooting
| Error | Cause | Fix |
|---|---|---|
Destination Host Unreachable | ARP failure on local network, missing route, or target host offline | → Full article |
Request timed out/ 100% packet loss | ICMP blocked by firewall, host down, or routing failure | Verify with TCP-based tools (
curl,
telnet); check firewall rules |
Name or service not known | DNS resolution failed for the hostname | Check DNS with
host or
dig; verify
/etc/resolv.conf |
| Very high RTT (>500 ms) | Network congestion, routing inefficiency, or saturated link | Use tracerouteto identify the slow hop |
Related Tools and Guides
The traceroute commandreveals the full network path to a host, identifying each router hop and its latency — use traceroute when ping fails and you need to find wherethe failure occurs. The host commandand the dig commanddiagnose DNS resolution issues that ping alone cannot distinguish from network failures.