ping Command: Tutorial & Examples
Send a network test packet
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
would use the following command:
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 (18.104.22.168) 56(84) bytes of data. 64 bytes from 22.214.171.124 (126.96.36.199): icmp_seq=1 ttl=55 time=84.9 ms 64 bytes from 188.8.131.52 (184.108.40.206): icmp_seq=2 ttl=55 time=85.0 ms 64 bytes from 220.127.116.11 (18.104.22.168): icmp_seq=3 ttl=55 time=84.9 ms 64 bytes from 22.214.171.124 (126.96.36.199): 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.
ping command is a useful tool for diagnosing connectivity issues and is available on most Linux distributions.
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.