ping Command

The ping command is a fundamental network utility used to test the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer.

Syntax

ping [OPTION]... HOST

Description

The ping command sends ICMP (Internet Control Message Protocol) echo request packets to the target host and listens for ICMP echo reply packets. It reports errors and packet loss, and provides a statistical summary of the results, including minimum, maximum, and average round-trip times.

Common uses include:

  • Verifying network connectivity to a remote host.
  • Measuring network latency (delay) between two hosts.
  • Troubleshooting network problems.
  • Checking if a server is up and responsive.

Common Options

Option Description
-c count Stop after sending count ECHO_REQUEST packets.
-i interval Wait interval seconds between sending each packet.
-s packetsize Specify the number of data bytes to be sent.
-t ttl Set the IP Time To Live.
-W timeout Time to wait for a response, in seconds.
-4 Use IPv4.
-6 Use IPv6.

Examples

Basic ping to a hostname

ping google.com

Pings google.com continuously until interrupted (Ctrl+C).

Ping with a specific count

ping -c 5 192.168.1.1

Sends 5 ICMP echo requests to 192.168.1.1.

Ping with a custom packet size

ping -s 1000 example.com

Sends packets of 1000 bytes to example.com.

Ping with a timeout

ping -c 1 -W 2 example.org

Sends one packet to example.org and waits for a response for 2 seconds.

Ping IPv6 address

ping -6 ipv6.google.com

Pings the IPv6 address of ipv6.google.com.

See also