HostArmada Web Hosting Knowledge Base

Knowledge is power! Use that power and achieve total and unconditional control over the Web Hosting Services!

How to use the ping command and how to perform a ping test on Linux.

The ping(Packet Internet Groper) command is perhaps the most widely used utility for diagnosing network connectivity issues. It works by sending one or more ICPM(Internet Control Message Protocol) packages to a destination usually defined within the command as an IP address, hostname, or domain name. After these packages are delivered, the sending server will await an ICPM reply back. The response time, usually in milliseconds, determines the time both servers need to start communicating. This time is also known as "latency", and the lower it is, the faster the connection.

The above characteristics of the command make it ideal for troubleshooting via a ping test and can help you get to the bottom of network-related issues.

Suppose no response is given from the destination server when sending the ping signals. In that case, this typically means that there is a connectivity problem, which may revolve around either of the IP addresses (the remote server or destination server), which the server listed inside its FireWall.

To execute the command and check if there is a connectivity issue with an IP address, hostname, or domain name, please type the following in your command-line interface:

ping <IP/hostname/domain> 

Here is a positive result when using it:

[[email protected] ~]# ping google.com
PING google.com (172.217.18.174) 56(84) bytes of data.
64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=1 ttl=58 time=0.716 ms
64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=2 ttl=58 time=0.865 ms
64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=3 ttl=58 time=1.01 ms
64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=4 ttl=58 time=0.859 ms
64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=5 ttl=58 time=1.06 ms

Note that before sending the ICPM request, the ping command converts the domain/hostname if used to an IP address first. When the command ends, or you interrupted it using a stop signal "CTRL + C" you will see a summary on the bottom of the screen, including the number of packets transmitted, the number of packets received and % packet loss, if such:

--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 0.716/0.903/1.065/0.126 ms

By default, ping will send packets until it is killed or receives an interrupt signal. However, you can define the number of echo packages it sends with an additional flag attached to it - "-c".

The last flag for the" ping" command we will discuss is the Internet Protocol flag, which you can add to it, essentially making it ping either an IPv4 or an IPv6 address. Here two examples:

[[email protected] ~]# ping -c 2 -4 google.com
PING google.com (172.217.16.142) 56(84) bytes of data.
64 bytes from fra15s46-in-f14.1e100.net (172.217.16.142): icmp_seq=1 ttl=58 time=0.786 ms
64 bytes from fra15s46-in-f14.1e100.net (172.217.16.142): icmp_seq=2 ttl=58 time=0.805 ms

--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.786/0.795/0.805/0.029 ms
[[email protected] ~]# ping -c 2 -6 google.com
PING google.com(fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e)) 56 data bytes
64 bytes from fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e): icmp_seq=1 ttl=58 time=0.729 ms
64 bytes from fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e): icmp_seq=2 ttl=58 time=0.735 ms

--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.729/0.732/0.735/0.003 ms

Was this article useful and on point?

Find out more about HostArmada entire range of optimized Web Hosting Services and take action today on improving your website Loading Speed, Security, and overall Stability!