LinuxCommandLibrary

ping

Test network connectivity

TLDR

Ping host

$ ping [host]
copy

Ping a host only a specific number of times
$ ping -c [count] [host]
copy

Ping host, specifying the interval in seconds between requests (default is 1 second)
$ ping -i [seconds] [host]
copy

Ping host without trying to lookup symbolic names for addresses
$ ping -n [host]
copy

Ping host and ring the bell when a packet is received (if your terminal supports it)
$ ping -a [host]
copy

Also display a message if no response was received
$ ping -O [host]
copy

Ping a host with specific number of pings, per-packet response timeout (-W), and total time limit (-w) of the entire ping run
$ ping -c [count] -W [seconds] -w [seconds] [host]
copy

SYNOPSIS

ping [options] destination

PARAMETERS

-c count
    Stop after sending count ECHO_REQUEST packets.

-i interval
    Wait interval seconds between sending each packet.

-t ttl
    Set the IP Time To Live.

-s packetsize
    Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

-q
    Quiet output. Nothing is displayed except the summary lines at startup time and when finished.

destination
    The IP address or hostname to ping.

DESCRIPTION

The ping command is a fundamental network diagnostic tool 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 a target host and waiting for ICMP echo reply packets.
The time taken for these packets to travel to the destination and back (round-trip time) is measured and displayed, providing an indication of network latency. ping can be used to verify that a host is reachable, measure the quality of the connection, and diagnose network problems such as dropped packets or high latency. It is a valuable tool for network administrators and developers. The command continues to send packets until interrupted by the user, providing a continuous stream of connectivity data. The command displays statistics such as packet loss and round-trip time averages, minimums, and maximums when interrupted.

CAVEATS

ping relies on ICMP, which can be blocked by firewalls, leading to false negatives. High packet loss rates may not always mean the server is down.

SECURITY CONSIDERATIONS

Flooding a network with ping requests can be used for denial-of-service (DoS) attacks. Some systems limit ICMP traffic to mitigate this risk. Additionally, the source IP address of ping packets can be spoofed, making it difficult to trace the origin of an attack.

HISTORY

ping was written by Mike Muuss in December 1983 as a tool to debug IP network problems. The name comes from the sonar terminology that represents an active sonar sending a pulse of sound and listening for an echo. Initially used on BSD Unix, it quickly became a standard tool across various operating systems.

SEE ALSO

Copied to clipboard