ping Command: Tutorial & Examples

Send a network test packet

The ping command is a Linux utility that allows you to send an Internet Control Message Protocol (ICMP) "echo request" to a remote server and receive an "echo response." It's commonly used to troubleshoot connectivity issues and to determine the round-trip time it takes for packets to be sent from your computer to the server and back.

To use the ping command, you will need to specify the domain name or IP address of the server that you want to ping. For example, to ping the server at www.example.com, you would use the following command:

ping www.example.com

By default, ping will send four ICMP echo requests and wait for a response from the server. If the server is reachable, it will send back an echo response for each request, and ping will display the round-trip time for each response. If the server is not reachable, ping will display an error message.

This is how the output may look like:

PING  (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=84.9 ms
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=2 ttl=55 time=85.0 ms
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=3 ttl=55 time=84.9 ms
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=4 ttl=55 time=85.0 ms

---  ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 84.926/84.957/85.020/0.037 ms

You can also use various options with the ping command to modify its behavior. For example, you can use the -c option to specify the number of echo requests that you want to send, or the -i option to specify the interval between requests.

ping -c 10 -i 2 www.example.com

This sends 10 echo requests to the host and uses and interval of two seconds.

The ping command is a useful tool for diagnosing connectivity issues and is available on most Linux distributions.

CleverUptime uses ping to detect if your servers can be reached from the internet. It is a good practice not to block ICMP request in your firewall as it makes network diagnostics much easier when the servers respond to echo requests.

The text above is licensed under CC BY-SA 4.0 CC BY SA