How to Ping on Linux [ Linux Ping Command ]

Today we will learn how to ping commands on Linux. Testing the concept of the ping command in Linux? If yes, then this is the right place where you can get complete information and command of Linux ping. Packet InterNet Groper is the full version of Ping.

The software/service determines whether a given IP address, host or server is available from your network.

The ping tool is often used to find and diagnose network errors. Its process is basic, but it saves time. It sends a packet to a given IP address/client/server address and measures the time it takes for that host to respond.

This is often referred to as latency. PING is one of the most popular methods of troubleshooting any link. For example, it would be feedback or echo. Ping sends a packet containing the message “PING” to a server/host and receives a copy of the message from that server/host. Ping determines the “round trip time” (or RTT) required for a packet to hit a specific server or host.

One of the most 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 specific network destination IP and waits for a response. When the shipment reaches its destination, it receives an ICMP echo reply.

You can use the ping command to check; Whether a remote destination, IP is working or not. You should check for packet loss and determine the round-trip delay during communication establishment. Ping is included in the iputils (or iputils-ping) kit, preinstalled on almost all Linux distributions. In this guide, we will explain what the ping command is, how to use Linux ping and brief information about how it works.

How to Ping on Linux [ Linux Ping Command ]

The ping command has the following syntax:
ping [OPTIONS] DESTINATION
To understand how the ping command works, let’s ping google.com:

ping google.com

The output of ping will be something like this:

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

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

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

64 byte's 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 will go over the most popular ping command options in the section provided below.

Option 1: Select the number of packets you want to transfer.

Ping will continue to transfer ICMP packets until an interrupt signal is received. Specify the number of echo request packets to send before the ping exits using the -c option followed by the number of packets to send before the ping exits:

ping -c 1 DESTINATION

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

ping -c 1 xyz.com

Option 2: How to select the source interface.

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

ping -I INTERFACE_NAME DESTINATION

Run the following command to ping example.com, using em2 as the source interface:

ping -I eth0 example.com

Option 3: How to specify Internet Protocol

Depending on your machine’s DNS settings, the ping command may use IPv4 or IPv6. If you are using IPv6, use the -6 option or ping6:

Pass the -4 option to use IPv4, or use its alias ping4:

ping -4 DESTINATION

Option 4: How to do ping timeout?

Use the -w option to stop pinging after a certain amount of time.

 ping -w 5 www.xyz.com

After 5 seconds, the ping will stop.

Option 5: How to PING Flooding

It is used to send the packet as fast as possible. It is used to evaluate a network’s efficiency.

ping -f www.xyz.com

Option 6: How to fill Data Packet

By using -p option, we can fill the packet with data. -p ff, for example, -p ff will fill the packet with the packet.

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

Option 7: How to Adjust Time Frame in Ping

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

ping -i 4 www.xyz.com
Conclusion

This article helped you understand the concept of ping commands in Linux. And how to ping in Linux and how to use Linux ping command. Learn the SED command in the Linux Operating system.

Scroll to Top