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.
Yum Install Ping Command
For installing the ping command follow the below-given steps:
Step 1: log in to your Linux server using SSH as the root user.
Step 2: Then you need to install the package required to use the ping command. So we will install the iputils package via yum install ping command.
yum install iputils
Then enter “y” and hit enter. Then you can ping the required IP address to check its status.
Getting iputil rpm on CentOS 8
For installing ping command in CentOS using RPM packages follow the steps below:
Step 1: Log into the CentOS8 server using root user.
Step 2: Then start downloading the iputil rpm from the CentOS website with the help of wget command.
Step 3: Then install the iputil package using the yum or rpm command.
yum install iputils-20180629-7.el8.x86_64.rpm
rpm -Uvh iputils-20180629-7.el8.x86_64.rpm
How to Ping in CentOS?
Use the following syntax for the ping command in CentOS.
ping [OPTIONS] DESTINATION
Here, we are using the google.com site to ping and get its details.
You will get the following output for this ping command.
PING google.com (188.8.131.52) 56(84) bytes of data.
64 bytes from muc11s01-in-f14.1e100.net (184.108.40.206): icmp_seq=1 ttl=53 time=40.2 ms
64 bytes from muc11s01-in-f14.1e100.net (220.127.116.11): icmp_seq=2 ttl=53 time=41.8 ms
64 bytes from muc11s01-in-f14.1e100.net (18.104.22.168): icmp_seq=3 ttl=53 time=47.4 ms
64 bytes from muc11s01-in-f14.1e100.net (22.214.171.124): icmp_seq=4 ttl=53 time=41.4 ms
--- 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 - (126.96.36.199).
- 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 get 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.
Specify the Number of Packets
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
More CentOS Ping Command Options
|Ping Option||The output of the Command|
||It will give a sound when a peer can be reached.|
||It will allow you to ping broadcast IP addresses.|
||Prevents the ping to change the source address of the probe.|
||It will limit you to send the number of ping requests.|
||It will set the SO-DEBUG option on the used socket.|
||This will Flood by sending hundreds of packets per second over a network.|
||This will inform you that how many successful packets have been transmitted into the specified time interval. By default value = 1 Second|
||I will help you st set your source IP address to a specified interface IP address. It is required while pinging IPv6 link-local address. For this, use an IP address or name of the device.|
||I will define the number of packets you can send without waiting for a response. You can specify the value higher than 3 and by giving yourself superuser permissions.|
||This will display IP addresses as output rather than hostnames.|
||This will show you quiet output that will ping line displayed and summary of the ping command at the end.|
||It will Set Time To Live.|
||It will give verbose output.|
||It will show the ping version and exit to a new command prompt line.|
||Before you exist a ping command, it will specify the time limit, regardless of how many packets have been sent or received.|
||It determines the time in seconds for which you need to wait for a response.|
From a network administrator's perspective, the ping is the most commonly used command in any Linux operating system. 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 centos ping commands that you can use on CentOS 8. If you wish to disable ping in CentOS, check out this in-depth blog post.
So this all about how to ping in centos and centos ping command, keep learning.
People Are Also Reading: