ping Command Reference: Flags, Usage & CI Examples
ping tests host reachability with ICMP echo requests.
ping sends ICMP echo requests and reports replies and round-trip times. It is a fast reachability and latency check, with the caveat that many networks block ICMP.
Common flags and usage
- -c <N>: send N packets then stop (always use in CI)
- -W <secs>: per-reply timeout
- -i <secs>: interval between packets
- -w <secs>: overall deadline
- -q: quiet summary output only
Example
shell
ping -c 3 -W 2 db.internal.example.com || echo "host unreachable or ICMP blocked"In CI
Always bound ping with -c so it does not run forever. A failed ping does not always mean the service is down -- many hosts and cloud networks block ICMP while serving TCP fine, so use nc -z for an actual port check.
Key takeaways
- ping checks reachability and latency via ICMP.
- Always use -c to bound the packet count in CI.
- ICMP is often blocked, so prefer nc -z for service checks.
Related guides
nc (netcat) Command Reference: Flags, Usage & CI ExamplesReference for nc/netcat: -z, -v, -w, -l, the port-probe pattern, and a CI example that waits for a TCP port t…
traceroute Command Reference: Flags, Usage & CI ExamplesReference for traceroute: -n, -m, -w, -T, the hop-by-hop diagnosis use, and a CI example that traces the path…
dig Command Reference: Flags, Usage & CI ExamplesReference for dig: +short, record types, @server, +trace, and a CI example that resolves a hostname to verify…