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

Linux Ping Command [CentOS, Debian, Ubuntu], How to Ping In Linux

Packet InterNet Groper is the full form for Ping. Software or service determines whether or not a given IP address, host, or server is available from your network. The ping tool is often used to look for and diagnose network errors. Its mechanism is basic, but it saves lives. It operates by sending a packet to the given IP address/client/server address and measuring the time it takes for that host to respond. 

01 Jun, 21 by Antoniy Yushkevych 5 min Read

A Detailed Breakdown of the Linux Ping Command

This is often referred to as latency. PING is the most popular method of troubleshooting any link. For an answer, it will respond or echo. Ping sends a packet containing the message "PING" to a server/host and receives a copy of the message from that host/server. Ping determines the "Round Trip Time" (or RTT) needed for a packet to hit a specific server or host.

One of the most commonly used methods for troubleshooting, monitoring, and diagnosing network access problems is the ping command. Ping sends one or more ICMP (Internet Control Message Protocol) Echo Request packets to a designated network destination IP and waits for a response. When the shipment arrives at its destination, it receives an ICMP echo reply. 

You can use the ping command to verify if a remote destination IP is working or not. You should also search for packet loss and determine the round-trip delay when communication is established once. Ping is included in the iputils (or iputils-ping) kit, pre-installed on almost all Linux distributions. In this guide, we will explain brief information on what ping is and how it works. 

 

What Is the Ping Command, and How Can I Use It?

The ping command has the following syntax:

ping [OPTIONS] DESTINATION

Let's ping google.com to help understand how the ping command works:

ping google.com

The output of the ping will be something like this:

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

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

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

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

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

^C

--- google.com ping statistics ---

We'll go into the most popular ping command options in the sections below.

Select the number of packets you want to transfer.

Ping will continuously transfer the ICMP packets until an interrupt signal is received. Using the -c alternative followed by the number of packages to send before ping exits to specify the number of Echo Request packages to send before ping exits:

ping -c 1 DESTINATION

To ping xyz.com just once, for example, you will type:

ping -c 1 xyz.com

Now you need to choose a source interface.

The ping command's default action is to deliver ICMP packages over the default path. If your computer has several interfaces, you can use the -I option to define the source interface:

ping -I INTERFACE_NAME DESTINATION

Using em2 as a source interface, run the following command to ping xyz.com:

ping -I em2 xyz.com

Specify the Internet Protocol

Depending on your machine's DNS settings, the ping command can use either IPv4 or IPv6. If you're using IPv6, use the -6 option or ping6:

ping -6 DESTINATION

Pass the -4 alternative to compel ping to use IPv4, or use its alias ping4:

ping -4 DESTINATION

How to Timeout? 

Use the -w alternative to interrupt pinging after a certain amount of time.

ping -w 5 www.xyz.com

After 5 seconds, the pinging will cease.

PING Flooding

It is used to send packets as quickly as possible. This is used to evaluate the efficiency of a network.

ping -f www.xyz.com

Filling Data Packet

Using the -p alternative, we can fill the packet with data. -p ff, for example, -p ff would fill the packet with ones.

ping -c 5 -p ff www.xyz.com

Adjust the Time Frame 

By default, ping waits 1 second before sending the next packet; however, the -i alternative can adjust this time.

ping -i 4 www.xyz.com

The ping delay has been increased to 4 seconds. Before each line in the ping output, add a timestamp. Add the -D option to the ping command if you want to record the time of day when you run it.

ping –D www.xyz.com

When a host is reachable, you'll hear an audible ping. When the –a switch is used, the device plays a sound when an answer from a host is sent.

When you're troubleshooting network problems and don't want to look at the computer before you get an answer, an audible ping will help.

ping –a www.xyz.com

 

Conclusion

Ping uses ICMP to send an ICMP echo message to the designated host, and then an ICMP returns a message if that host is open. Ping is usually calculated in milliseconds, and it comes pre-installed on any modern operating system. Ping is a network command-line interface for checking a host's IP-level reliability on a server.

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