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

Ping Command in Linux [How to Ping in Linux]

Ping command in Linux is the best solution to find that how your network connection is performing or also helpful while troubleshooting, testing, and diagnosing network connectivity issues. To help you to understand Linux ping command this article will guide you.

24 Sep, 21 by Antoniy Yushkevych 7 min Read

List of content you will read in this article:

Checking for the concept of Ping command in Linux? If yes, then this is the right place where you will get complete information and commands of Linux ping. Packet InterNet Groper is the full form for Ping. Software/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 time. 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.

This is often referred to as latency. PING is the most popular method of troubleshooting any link. For example, 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. Linux 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. 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 is ping command is, how to use Linux ping and how does it works. 

The ping command has the following syntax:

ping [OPTIONS] DESTINATION

Let's ping google.com to 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 below-given section.

Option 1: How to 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

Option 2: How 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 eth0 monovm.com

Option 3: How to 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 use IPv4, or use its alias ping4:

ping -4 DESTINATION

Option 4: How to Timeout Ping? 

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.

Option 5: How to 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

Option 5: How to 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

Option 6: How to Adjust the Time Frame in Ping

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

Ping Option Output of the Command
a It will give a sound when a peer can be reached.
b It will allows you to ping broadcast IP addresses.
B Prevents the ping to change the source address of the probe.
c (count) It will limit you to send the number of ping requests.
d It will set the SO-DEBUG option on the used socket.
f This will Flood by sending hundreds of packets per second over a network.
i (interval) This will inform you that how many successful packets have been transmitted into the specified time interval. By default value = 1 Second
I (interface address) I will help you st set your source IP address to a specified interface IP address. It is requires while pinging IPv6 link-local address. For this, use an IP address or name of the device.
l (preload) I will define a 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.
n This will display IP addresses as output rather than hostnames.
q This will show you quiet output that will ping line displayed and summary of the ping command at the end.
T (ttl) It will Set Time To Live.
v It will give verbose output.
V It will show the ping version and exit to a new command prompt line.
w (deadline) Before you exist a ping command, it will specify the time limit, regardless of how many packets have been sent or received.
W (timeout) It determines the time in seconds for which you need to wait for a response.

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.

This article helped you to understand the concept of ping command in Linux, how to. ping in Linux and how to use Linux ping command. If you have any more commands associated with Ping commands, please suggest them via the comment box listed below.

Keep Learning.

People Are Also Reading:

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