Introduction
Ping is a utility that allows you to test if a host or IP address responds using ICMP packets.
Procedure
Please note the IP addresses listed below are not IP addresses for their respective hosts and are included for demonstration purposes. IP addresses you see while testing will be different.
Ping accepts a hostname or an IP and will report any packet loss. The c flag limits the number of times the ping is attempted.Below is an example of a successful ping ten times:
[root@server ~]# ping -c10 example.tld
PING example.com (192.0.2.1) 56(84) bytes of data.
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=1 ttl=53 time=7.80 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=2 ttl=53 time=7.82 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=3 ttl=53 time=7.82 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=4 ttl=53 time=7.81 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=5 ttl=53 time=8.30 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=6 ttl=53 time=7.77 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=7 ttl=53 time=7.89 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=8 ttl=53 time=7.89 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=9 ttl=53 time=7.81 ms
64 bytes from 192.0.2.1 (192.0.2.1): icmp_seq=10 ttl=53 time=7.85 ms
--- example.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 7.777/7.879/8.305/0.175 ms
In the following example, we run ping on the example.org host but cannot reach it from our server, as we get 100% packet loss after sending five packets:
[root@server ~]# ping -c5 example.tld
PING example.org (192.0.2.2) 56(84) bytes of data.
--- example.org ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms
Since ping uses ICMP packets and it's common for providers to block these packets, another testing method should be used to determine if there are network issues. Traceroute can be used with TCP to avoid any ICMP blocks:
How to use the traceroute command