ping
Test network connectivity
TLDR
Ping host
Ping a host only a specific number of times
Ping host, specifying the interval in seconds between requests (default is 1 second)
Ping host without trying to lookup symbolic names for addresses
Ping host and ring the bell when a packet is received (if your terminal supports it)
Also display a message if no response was received
Ping a host with specific number of pings, per-packet response timeout (-W), and total time limit (-w) of the entire ping run
SYNOPSIS
ping [OPTIONS] destination
The destination can be an IP address (e.g., 192.168.1.1) or a hostname (e.g., example.com).
PARAMETERS
-c count
Stop after sending count ECHO_REQUEST packets. Useful for sending a fixed number of pings.
-i interval
Wait interval seconds between sending each packet. Default is one second. Decreasing this value requires root privileges.
-s packetsize
Specify the number of data bytes to be sent. The default is 56 (resulting in 64 bytes on the wire, including ICMP header).
-t ttl
Set the IP Time To Live (TTL) value. This limits the number of hops a packet can traverse before being discarded.
-W timeout
Time in seconds to wait for a response for each packet. If a response is not received within this time, the packet is considered lost.
-4
Force IPv4. Used to explicitly choose IPv4 addressing.
-6
Force IPv6. Used to explicitly choose IPv6 addressing.
-q
Quiet output. Nothing is displayed except the summary lines at startup and when finished. Useful for scripting.
-v
Verbose output. Displays all ICMP packets other than echo replies.
DESCRIPTION
The ping command is a fundamental network diagnostic utility used to test the reachability of a host on an Internet Protocol (IP) network. It operates by sending Internet Control Message Protocol (ICMP) ECHO_REQUEST packets to the target host and listening for ECHO_REPLY messages. The command provides valuable information such as the round-trip time for packets to reach the destination and return, along with the Time To Live (TTL) value and packet sequence numbers. This data helps in determining if a host is alive, assessing network latency, and identifying packet loss. By default, ping sends one packet per second indefinitely until interrupted by the user (Ctrl+C). Users can specify various options to control the number of packets sent, the interval between packets, packet size, and more. It's an indispensable tool for network administrators and users alike for basic network troubleshooting, verifying connectivity, and diagnosing connectivity problems, including DNS resolution issues (if using a hostname).
CAVEATS
ping relies on ICMP, which can be blocked by firewalls on target hosts or intermediary network devices, leading to apparent "unreachability" even if the host is operational for other services (e.g., HTTP). Therefore, a failed ping doesn't always mean the host is completely offline, only that ICMP echo requests are not being responded to. Some advanced options, like setting a very small interval (e.g., -i 0.2), may require root privileges. Furthermore, ping only tests basic network layer connectivity; it doesn't guarantee that application-layer services (like a web server) are running or accessible.
EXIT STATUS
Upon completion, ping returns an exit status of 0 if at least one ECHO_REPLY was received, and 1 if no packets were received or an error occurred. This makes it suitable for use in scripts to check host availability.
NETWORK TROUBLESHOOTING
ping is often the first command used when troubleshooting network connectivity issues. A successful ping confirms basic IP layer reachability, while a failed ping points to issues like host being down, network configuration problems, or firewall blocks. Combined with traceroute, it helps pinpoint where connectivity breaks down.
HISTORY
The ping command was written by Mike Muuss in December 1983 as a tool to troubleshoot network problems. Its name derives from the sonar terminology, where a pulse of sound is sent out and a return "ping" is awaited to detect objects. Muuss designed it to use ICMP echo packets for network diagnostics, making it an early and enduring utility for verifying host reachability and measuring round-trip times on IP networks.
SEE ALSO
traceroute(8), netstat(8), ip(8), dig(1)