One of the most continually used tools by network administrators is the ping command. Over a half-century has passed since it was unleashed, and unsurprisingly, it has proven effective in troubleshooting networks.
Testing the availability of a networking device on a network (mostly computers) can be done by employing the ping command. In order to check the connectivity between hosts and servers, the PING (Packet Internet Groper) command is utilized.
Using IP addresses or URLs as input, this command transmits a data packet to the specified address with the message "PING" and gets a response from the server/host. when the ping speed is high and the latency is low.
In Ping, an ICMP echo message is sent to the specified host using Internet Control Message Protocol (ICMP). If the host is functional, an ICMP reply message is sent back. Contemporary operating systems come with this ping enabled, which is normally estimated in milliseconds.
Table Of Contents
- What is Ping command?
- Basics of the Ping Command
- How does Ping command works?
- Troubleshooting with ping
- Ping syntax for Linux
- Standard Ping commands for Linux
What is Ping command?
Pings are primary Internet software programs that enable users to check and verify whether specific destination IP addresses exist and are capable of accepting requests in computer networks.
Ping can also be utilized as an analytical tool to verify that a host computer that the user is trying to reach is operational. Ping can be used by most embedded network administration software, including any operating system with networking capabilities.
An IP network is tested by the ping command if it is possible to reach the host. Many Unix and Linux systems use 64 bytes instead of 32 bytes as the default ping size on Windows.
Besides Windows and Linux, macOS also supports this command. Generally, ping is used to execute the following tasks:
- Validate the setup of the network
- A remote computer's connectivity is tested
- Determine a remote system's IP address
- Awaken remote systems
Using this command, you will be able to install the latest ping version.
sudo ping -v
Basics of the Ping Command
All operating systems use ping as their default command. By using it, you can estimate how long it will take you to attain your target. A Ping packet is sent to the destination using the Internet Control Message Protocol (ICMP).
Following that, it awaits the echo reply. Statistics can be displayed for this request, as well as errors and packet losses. Ping commands are typically preceded by ping, followed by a hostname, website name, or exact IP address.
ping [options] hostname or IP address
Our terminal will display the following information when we are checking if the remote host is up:
By hitting the Ctrl+C keys, we can stop the process.
- from: It displays the IP address and the target.
- important: It is possible for IP addresses to vary depending on our geographic location when visiting a website.
- ttl: There is a value, which is Time to Live from 1-255. In addition, it indicates how many hops a packet could take before being removed from the network by any router.
- icmp_seq: ICMP packets' sequence numbers are shown here. For subsequent echo requests, the number increases by a single digit.
- time: Describes the length of time a packet took to arrive at a destination and return to the origin. The time is expressed in milliseconds (ms).
When we encounter problems with a remote computer or website, pinging the local host will ensure that we have a strong connection. The local network interface can be analyzed using any of the techniques detailed below:
- The quickest way to ping a localhost is with ping 0 (or zero). The terminal will determine and recognize the IP address when this command is entered.
- It is possible to imply the name ping localhost for pinging localhost. This command should be entered and say ping this system every time we mention this system.
- It is also attainable to ping the localhost applying the IP address ping (IP address). A typical example would be as follows:
How does Ping command works?
Using ping, you can troubleshoot a connection. Generally, this tool is used to detect a connection between two machines. For say, to find out if a device is offline, you might use ping to check the connection to a network printer.
By using this command, you can confine whether a server is running. In addition, it can be used to resolve varied connectivity issues.
- Inspect the network for latency or dropped packages and other issues.
- A test of your internet connection will be conducted.
- Ensure that remote machines are online.
The ping command works by sending a small packet of data called an
ICMP Echo Request to a target device, and then waiting for a response called an
ICMP Echo Reply.
If the target device responds, it means that it is reachable on the network and that there are no major issues with the network connection.
If the target device does not respond, it could indicate that there is a problem with the network connection or that the target device is offline or otherwise unavailable.
When the ping command is used, the output shows how much time it takes each transmitting a packet from source to destination. To analyze the validity of the connection, several pings are initiated.
The default setting for Ping normally sends four or five echo requests. Responses are printed until the terminal is disabled. An overview of ping statistics is shown at the end of every session. Including:
- The Time to Live (TTL)
- Transmission and reception of bytes
- Time taken for a round-trip (ms)
- Statistical data on packet loss
Troubleshooting with ping
The most basic version of ping requires only the destination and the command, such as a name or IP address. It is easy to use ping in scripts since it is a command-line utility.
To review the output of ping commands later, an administrator can run multiple pings, record their usage, and save the results to a text file for review. The starting point in conventional network troubleshooting is to ping.
For instance, it only takes a few keystrokes to ping an IP address by entering
220.127.116.11. If it is successful, note that the machines communicate with one another, and the IP address is active.
The first step in troubleshooting an application hosted over a server network is to determine whether the connection is working using ping commands. The server or application is at fault if your ping responds with quicker response times.
Ping allows you to verify network connections on almost any device connected to the internet, making it highly beneficial. The ping command, for instance, can be used to test the speed and throughput of routers or servers.
Moreover, you presumably encounter an issue with your network if a ping displays a successful connection but takes longer than expected to respond.
The ping command can be run individually or automatically as part of a pre-organized task to keep track of network performance. A failed ping indicates a problem. Besides, the ping command allows you to check the functionality of websites and see if there are any connection issues.
Ping Syntax for Linux
The following command needs to be entered into the Terminal to get the ping syntax on a Linux or macOS:
|a||as soon as it reaches the target device, it makes a sound.|
|b||by using this command, you can ping an IP address that has been broadcast.|
|B||makes sure the source IP address does not change when pinging.|
|c (count)||determine how many pings will be sent.|
|d||using SO-DEBUG on the socket.|
|f||several ping packets are sent per second to flood the network.|
|i (interval)||count of successful transmissions, in seconds.|
|I (interface address)||identifies the source IP address of a specified interface.|
|1 (preload)||an excessive number of echoes sent before waiting for replies.|
|n||inspite of IP addresses, it displays hostnames as output.|
|q||a quiet output is displayed. The ping command is summarized at the end of one line.|
|T (ttl)||time to live value.|
|v||furnishes verbose output.|
|V||make sure that you are using the latest version of ping.|
|w (deadline)||the ping command exits after a certain period of time, nevertheless of how many packets were sent or received.|
|W (timeout)||confines the period of time to wait for a response, in seconds.|
|-? (Help)||exhibits usage and syntax for ping.|
Standard Ping commands for Linux
The following are some more Linux users' applications for the ping command:
1. Modify the interval between ping packets
ping command, the
-i option specifies the interval, in seconds, between sending successive ping packets. The default value is 1 second.
ping -i 6 namlabs.com
You can also specify a fractional value, such as
0.2, to send pings more frequently. However, note that the actual interval may be slightly longer due to the time it takes to process the ping command and send the packet.
2. Choose how many pings to send
This option specifies the number of ping packets to send. Depending on how many echo messages you want to send, you can set the number.
For example, the following command sends 5 ping packets to
ping www.replaybird.com -c 5
ping command will send the specified number of packets and then exit. If you want to continuously send ping packets, you can use the
-c option with a large value or omit it entirely.
3. Verify version
-V option is used to display the version number of the
This will display the version number of the
ping command that is installed on your system.
Note that the
-V option is a capital "V", not a lowercase "v". The lowercase
-v option enables verbose output.
4. Ping quiet mode
-q option enables "quiet" output. This causes the
ping command to suppress the normal output and only display a summary at the end.
For example, the following command sends 5 ping packets to
google.com with quiet output:
ping www.pagesmeter.com -q
ping command will not display any output until it has finished sending all of the packets. At the end, it will display a summary of the results, including the number of packets transmitted, the number received, and the packet loss.
5. Modify the packet size
It specifies the size, in bytes, of the ping packet. By default, the
ping command sends packets that are 56 bytes in size.
For example, the following command sends 5 ping packets that are 100 bytes in size to
ping -c 5 -s 100 uiinspector.com
-s option can be used to test the maximum transmission unit (MTU) of a network or to test the performance of a network with different packet sizes. However, note that some systems may block or drop ping packets that are larger than a certain size.
If you want to send the maximum possible size of a ping packet, you can use the
-s option with a value of
65500 or higher. This will send a packet that is as large as possible, given the maximum IP packet size and the overhead of the IP and ICMP headers.
6. Configure ping timeout duration
This instance will cause the ping to end after 15 seconds. No matter how many packets are sent or received, it will terminate.
-w option specifies the deadline, in seconds, for sending or receiving a ping packet. If a packet is not sent or received within the specified time, the
ping command will exit with an error.
For example, the following command sets the deadline to 4 seconds:
ping -w 4 replaybird.com
ping command will send packets and wait up to 4 seconds for a response for each packet. If a response is not received within the deadline, the
ping command will exit with an error.
-w option can be used to specify a longer timeout for ping packets, which can be useful if you are pinging a host over a slow or congested network.
However, note that the actual timeout may be slightly longer due to the time it takes to process the ping command and send the packet.
The last shot
Using Ping, you can verify the network connection locally as well as remotely. Testing and troubleshooting network speed and connectivity problems in Linux can be done instantly with the ping command.
An IP address or hostname is pinged by sending data packets and checking how long it takes for a response to arrive. All operating systems use the ping command.
This tool can help you figure out how long it will take to reach your objective. Likewise, the term is used to define the speed at which data signals travel between a computer and a website.
Besides testing connectivity and determining response time, ping is also used for troubleshooting. Determine the IP address of a URL by pinging it. You can use the ping command to find out the IP address of a particular URL.
Monitor Your Entire Application with Atatus
Atatus is a Full Stack Observability Platform that lets you review problems as if they happened in your application. Instead of guessing why errors happen or asking users for screenshots and log dumps, Atatus lets you replay the session to quickly understand what went wrong.
We offer Application Performance Monitoring, Real User Monitoring, Server Monitoring, Logs Monitoring, Synthetic Monitoring, Uptime Monitoring and API Analytics. It works perfectly with any application, regardless of framework, and has plugins.
Atatus can be beneficial to your business, which provides a comprehensive view of your application, including how it works, where performance bottlenecks exist, which users are most impacted, and which errors break your code for your frontend, backend, and infrastructure.
If you are not yet a Atatus customer, you can sign up for a 14-day free trial .