How to Use the Ping Command for Network and Troubleshooting

Steve Manjaly August 8, 2022
- 7 min read

The ping command is one of network admins' most commonly used tools. It has served and continues to serve network admins as one of the best network troubleshooting tools since it was released almost 39 years ago. 

In this article, we cover what the ping command does, how to use it, and more. Read on to learn the basics about this simple but powerful networking tool that IT teams can’t live without. 

What does the ping command do?

The ping command tests if you can reach a host through an IP network. 

When a user uses a ping command, an Internet Control Message Protocol (ICMP) echo request is sent to the destination. ICMP is a network layer protocol part of the IP suite. If the host’s configuration is to respond and the ping echo request reaches the host, it will send an echo reply with the same payload as the echo request. 

The default ping size on Windows is 32 bytes, while many Unix or Linux systems use 64 bytes. Aside from Windows and Linux, the command is also available on macOS. In fact, you can find it in almost all versions of Unix, as well as most other operations. 

In common IT scenarios, the ping command is used to: 

  • Test the connectivity of a remote machine 
  • Test network configuration
  • Wake up remote systems
  • Find out the IP address of a remote system

Ping syntax 

The syntax for a basic ping command is similar for both Windows and Linux systems. It’s just "ping" followed by the destination URL or IP address. For example:

ping www.facebook.com 

or

ping 157.240.23.35

The syntax for a basic ping command is similar for both Windows and Linux systems. It’s just ‘ping’ followed by the destination URL or IP address.

The ping command also offers a set of options for network troubleshooting. While the possibilities or option switches are different for Windows and Linux systems, the syntax is similar: ping followed by option followed by the option parameters followed by the destination URL or IP address. 

For example, in Windows systems, to ping facebook.com with 5 echo requests, the command will look like this:

ping /n 5 www.facebook.com 

The ping command also offers a set of options for network troubleshooting. While the possibilities or option switches are different for Windows and Linux systems, the syntax is similar.

You can, of course, use multiple options at the same time. 

For example, if you want to ping www.facebook.com with 3 echo requests, each with a Data field size of 100 bytes, the command will look like this:

ping /n 3 /l 100 www.facebook.com

If you want to ping www.facebook.com with 3 echo requests, each with a Data field size of 100 bytes, the command will look like this.

Ping command options in Windows

  • /t - this is used for sending repeated echo requests until it is uninterrupted. In Windows systems, a single ping command sends 4 echo requests unless specified. The commands look like this: ping /t www.facebook.com
    In Linux, the system sends ping requests continuously unless interrupted.
  • /n - as mentioned earlier, is to set the number of ICMP packets sent with the ping command. For example, to send 5 ICMP echo requests to Facebook, the command will look like: ping -n/ 5 www.facebook.com
  • /a - to resolve hostname from IP address. For example: ping -a 157.240.23.19

Ping command options in Windows.

Ping command options for Linux

  • -c - to specify the number of ICMP packets sent with the ping command. For example: ping -c 6 www.facebook.com
  • -i - to set the interval between packets. By default, the interval is one second. For example, to set 7 seconds: ping -i 7 www.facebook.com
  • -f - to send the maximum number of packets at the highest speeds allowed by the network. For example: ping -f www.facebook.com

How to use the ping command?

In Windows, open the command prompt and simply type the ping command with the appropriate options. For example, to ping Facebook 7 times, type:

ping -n/ 5 www.facebook.com

How to use the ping command in Windows.

The results of sending each packet will be displayed below. 

In Linux systems, open the terminal and type the ping command. For example, to ping Facebook 5 times at an interval of 10 seconds:

ping -c 5 -i 10 www.facebook.com

How to read a ping test?

The first line of the results will show the hostname and the number of bytes sent. 

How to read a ping test? The first line of the results will show the hostname and the number of bytes sent.

The following few lines will tell you the echo reply from the host for each of the ICMP packets that were sent with the ping command. In the example below, four echo replies were received. 

How to read a ping command? The following few lines will tell you the echo reply from the host for each of the ICMP packets that were sent with the ping command.

The bytes show the number of bytes sent back as the reply. This is usually the same as the number of bytes sent. Time entry is the number of milliseconds it took for the host to receive the request and send back an echo reply. 

The TTL value represents the number of hops the packet traveled through to reach your system. These packets in the above example had 71 hops before they returned. 

The following few lines show the statistics for the entire ping command. In the below example, four packets were sent and none were lost. And the average round trip time for these packets was 16 milliseconds. 

How to read a ping command? The following few lines show the statistics for the entire ping command.

Ping command examples

The ping command has many use cases. Obviously, the primary use case is to see if a remote system can be reached. Just send a ping to the host, be it a server or any remote system, and if it pings back, it means it's alive and kicking. 

You can also set up a repeating ping command to a server to monitor its status. For example, you can set up repeated echo requests on a Windows system until interrupted using the following command. 

ping /t hostname 

In Linux, ping is repeated unless the number of echo requests is specified. Here you can also set the time interval between each ping. For example, you can ping a host every 60 seconds with this command: 

ping -1 60 hostname

There are also tools with which you can configure your system to send ping commands as a response to an event. 

You can also use the ping command to figure out connectivity issues in your network. For example, if you’re not able to reach a website or a remote server over IP you can use this command to ping your router:  

ping 127.0.0.1

If you’re getting a response, it means the connection from your system to your router is working properly and the issue is beyond your router. 

If the response comes back as "unknown host," your system could not send the ping. This could indicate problems on your end, or the destination you’re trying to reach doesn’t exist. But if the response was "timeout," it means that your system sent the ping, but the destination didn’t send back a reply. 

You can also configure the ping command to run continuously in specific intervals. This can help you constantly monitor remote systems

Try to use the command to see how your network responds under high load conditions. With this command, your system will send maximum echo requests at the highest speeds possible. You can analyze your network with the results of this command:

ping -f hostname

Key takeaways

The ping command is commonly used for troubleshooting network issues. The command sends ICMP packets to the host or the destination as ICMP echo requests. The host sends ICMP packets as a reply, and the system computes the time it took and displays the results. 

To use the ping command, just type ping followed by the hostname or the URL in the command prompt for Windows systems. For Linux systems, type the same command in the terminal. Don't forget that the command syntax looks like this:

ping hostname

Ping command offers several options. They are different for Linux and Windows systems. But the general syntax is ping option hostname. 

Besides testing the reachability of a host, you can use the ping command to monitor a service or a system continuously. You can also use it to troubleshoot your network and test your network configuration. 

Frequently Asked Questions 

What does ping stand for?

The word ping was not intended as an acronym when the tool was designed. But the word has been expanded for a long time as Packet InterNet Groper

What is the most common use of a ping command?

The most common use of the ping command is to find if a server or a remote system is reachable over an IP network. 

What’s the difference between ping and pathping commands?

The ping command only gives the time it took for a packet to travel from the source to the destination. It ignores all the hops the packet makes to reach the destination. 

Meanwhile, pathping displays all the routers the packet goes through, the time it took to reach them, and information such as packet loss. 

Read other articles like this : Network administrator

Evaluate InvGate as Your ITSM Solution

30-day free trial - No credit card needed