Special offer
popup-offers
English
+370 5 205 5502 sales@monovm.com

How to Ping in CentOS [Install Ping Command in CentOS]

How to Ping in CentOS? Today's tutorial focuses on the ping command in CentOS and how to ping a website (or IP address) in CentOS. Read on to find out.

24 Sep, 21 by Antoniy Yushkevych 6 min Read

List of content you will read in this article:

Linux is one of the most reliable, robust, and stable open-source operating systems. You can leverage various flavors of Linux distribution and CentOS 8 is one of them. One of the most special features of Linux distributions is various commands that can solve various tasks easily. You can simply use the command-line interface for running the commands and one of the commands is the Linux ping command.

You can use the ping command for troubleshooting, testing, and diagnosing the connectivity issues of the network. The ping command allows you to send multiple ICMP (internet control message protocol) echo request packages to the other host available over the network. These packages are being sent to a specific IP address available on the network that must be waiting for a reply. Whenever the package has been received by the destination, it will respond using an ICMP echo reply.

There are various uses of the ping command. Using the ping command, you will be able to determine whether the remote IP address is active or inactive. Apart from this, the Linux ping will help you in finding the delay for the round-trip communication and check if any of the packets is missing while transmitting.

The ping command comes as a part of the iputils package. This package is generally pre-installed on every distribution of Linux. Not only this, you can find it on Windows, macOS, and FreeBSD.

For installing the ping command, first, log in to your Linux server using the SSH as the root user. Then you need to install the package required to use the ping command. So we will install the iputils package via yum command. Then enter “y” and hit enter. Then you can ping the required IP address to check its status.

 

For this, first, log into the CentOS8 server using root user. Then start downloading the iputil rpm from the CentOS website with the help of wget command. Then install the iputil package using the yum or rpm command.

 

Use the following syntax for the ping command.

ping [OPTIONS] DESTINATION

Here, we are using the google.com site to ping and get its details.

ping google.com

You will get the following output for this ping command.

PING google.com (172.217.22.206) 56(84) bytes of data.

64 bytes from muc11s01-in-f14.1e100.net (172.217.22.206): icmp_seq=1 ttl=53 time=40.2 ms

64 bytes from muc11s01-in-f14.1e100.net (172.217.22.206): icmp_seq=2 ttl=53 time=41.8 ms

64 bytes from muc11s01-in-f14.1e100.net (172.217.22.206): icmp_seq=3 ttl=53 time=47.4 ms

64 bytes from muc11s01-in-f14.1e100.net (172.217.22.206): icmp_seq=4 ttl=53 time=41.4 ms

^C

--- google.com ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 7ms

rtt min/avg/max/mdev = 40.163/42.700/47.408/2.790 ms

The ping command will help in resolving the domain name to the IP address and start with sending the ICMP packages to the IP address of the destined location. If in case, you will get the destination reachable then it will definitely respond back and the output displays a line that will contain the below fields.

  • By default, the number of data bytes being sent is 56 and later gets translated into 64 ICMP data bytes - 64 bytes.
  • The destination’s IP address - (172.217.22.206).
  • For each sent packet the ICMP sequence number is specified as the icmp_seq=1.
  • The Time to Live is defined by. - ttl=53 -
  • The ping time, generally measured in milliseconds which is considered to be the round trip time for the packet for reaching the host and providing back the response to the sender. - time=41.4 ms.

Generally, the interval that stands between sending a new packet is one second. With the help of the ping command, you will be able to send ICMP packets to the specified destination IP address until you get interrupted by an interrupt. If you want to stop the command in between, then hit ctrl+C. After the command has been stopped, you will get statistics on the screen along with the packet loss details. If there is a packet loss, then some of your data gets lost somewhere on the network due to some network issue. For checking the packet loss, you can run the traceroute command. 

If you do not get a reply for the ping command, it means there is a network issue or the communication is not established yet. It may be the case that either the IP address is not active or the host is having a firewall that is blocking the ICMP traffic.

As we have already mentioned, the ping command will send the ICMP packages continuously until an interruption. In order to specify the total number of echo request packages that are being sent after which the ping command exits, you can use the -c option along with the number of packages.

ping -c 1 DESTINATION

In order to specify the Source Interface

The ping command uses the default route for sending the ICMP packages. If you have several interfaces present on your system, then you have to specify the source interface along with -i option as shown below.

ping -I INTERFACE_NAME DESTINATION

In order to specify the Internet Protocol

If you are using the ping command, you need to use either IPv4 or IPv6 internet protocol but it totally depends on the machine’s DNS settings. 

For forcing the ping command, you need to use IPv4, using the -4 option, or using its alias ping4:

ping -4 DESTINATION_host

For using the IPv6 protocol, you can provide the -6 option or using ping6:

ping -6 DESTINATION_host

From a network administrator's perspective, the ping is the most commonly used command. It will help you in troubleshooting the network and its communication to other hosts. It is provided as a network utility that helps in testing the IP level; connectivity of the specified host present on the network.

We have mentioned some of the basic ping commands that you can use on CentOS 8. If you wish to disable ping in CentOS, check out this in-depth blog post.       

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com