The ping command is one of the most used commands by IT professionals to test the network connection. With the ping cmd, we can send a small data packet to a computer, server, or another network device to check the connectivity.
This ping cmd not only tells us if we can reach the device over the network but also how long it took and if packets were lost or not. This information tells us something about the quality of the network connection.
The ping cmd is a simple command to use, in this article I will give you some tips to get more out of it.
- How to use the Ping Command
- Ping Command Options
- Troubleshoot network issues with cmd ping
- Reading the Ping Results
- Ping Latency
- Finding network issues with the Ping Cmd
- Cmd ping Conclusion
How to use the Ping Command
With the ping cmd, we can quickly check if a computer is able to access the internet. In the steps below we are going to send a ping test command to the servers of Google.
You can run the ping cmd from every terminal, like Command Prompt, PowerShell.
Running a Ping on Windows
- Open the Start Menu or press Windows key + R
- Type cmd and press enter
- In the command promt, type:
ping 188.8.131.52and press enter
- Examine the result of the ping command:
What we see in the results are the replies from the DNS server (184.108.40.206) of Google. The ping cmd has sent four packages of 32 bytes (which is really small and it took 10ms to send the package and receive the acknowledgment.
The TTL indicates the time-to-live of the package. If the response from Google takes longer than 118ms then the package is discarded.
On the last lines, we will see the statics of the command, in total there are 4 packages sent, all four are received and none was lost. On average, it took 11ms to receive the response.
Ping Command Options
The basic ping command will do fine for small and simple tests, but with some options, you can make the ping cmd more useful for troubleshooting potential network problems.
Ping -t – Continuous Ping CMD
The ping -t command is the Continuous Ping CMD, something I use pretty often. Let’s say you want to restart your router, now you could repeatedly press F5 to check if the router is back online.
ping -t cmd you can let the ping run continuously, so you can see when the router is offline and when it comes back online.
❯ ping -t 192.168.1.1 Pinging 192.168.1.1 with 32 bytes of data: Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=5ms TTL=64 Reply from 192.168.1.82: Destination host unreachable. # Router Offline Reply from 192.168.1.82: Destination host unreachable. # Router Offline Reply from 192.168.1.1: bytes=32 time=6ms TTL=64 # Router back online Reply from 192.168.1.1: bytes=32 time=1ms TTL=64 Reply from 192.168.1.1: bytes=32 time=5ms TTL=64 Ping statistics for 192.168.1.1: Packets: Sent = 8, Received = 6, Lost = 2 (25% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 8ms, Average = 4ms
As you can see in the results above, the host (router in this case) was for a brief moment unreachable and then came back online.
Ping -l – Increase package size
If you are troubleshooting network issues it’s sometimes a good idea to increase the packet size that is sent during the ping. Some network problems only occur when more data is sent. With the
ping -l (L) command you can change the size of the packets.
C:\>ping -l 1024 192.168.1.1 Pinging 192.168.1.1 with 1024 bytes of data: Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=3ms TTL=64 Reply from 192.168.1.1: bytes=1024 time=1ms TTL=64
Here we are sending packets of 1024 bytes to the router with IP Address 192.168.1.1.
Ping -n – Number of Pings
ping -n command you can specify the number of pings you want to run. So instead of the default 4 or the continuous ping with -t, you can ping a host 10 times for example. Not something I really use often, but it might come in handy if you have some performance issue that you want to check.
ping -n 10 192.168.1.1
Ping -a – Resolve the hostname
We can also use the ping cmd to resolve the name of the device that is using an IP Address. This feature is great if you want to know which device is using a particular IP Address.
Let’s say we want to know which device is using the IP Address 192.168.1.25. For this, we can use the
ping -a command:
ping -a 192.168.1.25 # Result Pinging tado.localdomain [192.168.1.25] with 32 bytes of data: Reply from 192.168.1.25: bytes=32 time=2ms TTL=64 Reply from 192.168.1.25: bytes=32 time=4ms TTL=64 Reply from 192.168.1.25: bytes=32 time=1ms TTL=64
As you can see in the results, the IP Address 192.168.1.25 belongs to Tado.
Troubleshoot network issues with cmd ping
The ping test cmd is primarily used to troubleshoot network-related issues. Before we can troubleshoot we first need to have a good understanding of our network layout.
Taken the example above, let’s say we are working on the laptop and we want to test if we have a good wireless network connection.
The first thing we do is ping the Router at 192.168.10.254. You can find the IP Address of your router by typing
ipconfig in the command prompt or PowerShell window:
Check if you can reach the router by typing:
# replace the IP Address with the address of your router ping 192.168.10.254
This command will send 4 packets of 32 bytes from your computer to the router. During the ping you will see the results of each packet that is sent and a summary:
Pinging 192.168.10.254 with 32 bytes of data: Reply from 192.168.10.254: bytes=32 time=1ms TTL=64 Reply from 192.168.10.254: bytes=32 time=1ms TTL=64 Reply from 192.168.10.254: bytes=32 time=1ms TTL=64 Reply from 192.168.10.254: bytes=32 time=1ms TTL=64 Ping statistics for 192.168.10.254: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 1ms, Average = 1ms
As you can see in the results we have a successful connection to the router. All the packages arrived.
The next step is to ping the modem, at 192.168.0.1. If we can reach the modem as well, then the last step is to ping something on the internet.
Ping Google cmd
The easiest option to test if you can reach the internet is to ping google. We can ping the IP Address of one of the DNS servers from Google at 220.127.116.11.
# Ping Google cmd ping 18.104.22.168 # Result Pinging 22.214.171.124 with 32 bytes of data: Reply from 126.96.36.199: bytes=32 time=10ms TTL=118 Reply from 188.8.131.52: bytes=32 time=15ms TTL=118 Reply from 184.108.40.206: bytes=32 time=10ms TTL=118 Reply from 220.127.116.11: bytes=32 time=10ms TTL=118 Ping statistics for 18.104.22.168: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 10ms, Maximum = 15ms, Average = 11ms
You can also test all the network devices with one command, pathping. This will test every hop between your computer and the network device that you try to reach.
Reading the Ping Results
So if we look at the result above, we see some different values, but what do they all mean? By default, ping will send 4 packets of 32 bytes to the requested Ip Address. For each packet we see the result, in this case, 192.168.10.254 has replied in 1ms.
Reply from 192.168.10.254: bytes=32 time=1ms TTL=64
- Bytes indicates the size of the packet that was sent. We can change this by using the -l switch.
- Time is how long it took for the response to come back (latency), in this case, 1ms.
- TTL is how long a packet should live (Time to Live). This is not in ms, but how many hops a network packet can take before it’s dropped. Each hop (network device) that the packet comes through lowers the TTL until it reached 0. This is to protect your network from an endless loop of network packages that couldn’t find their destination.
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
At the end of the result, we see how many packets were sent in total and how many of them were lost. You want a 0% loss, of course, if you start losing the package then you should narrow it down to find in which part of the network the loss occurred.
Now, this is was a simple internal network test. A response time of 1ms for your home network is what you want. Any longer indicates that something isn’t optimal.
You can use ping to check if you can reach a host, but most of the time when you are troubleshooting a network you are more interested in the ping latency. The lower the latency the faster the connection is between you and the host. A ping time of 100ms is really high, between the 10ms and 20ms is more common.
The amount of latency you have depends on a lot of factors. Are you connected to WiFi or cable? What kind of internet connection do you have? Where are you located compared to the host geographically?
There are a few general guidelines when it comes to latency:
- Your latency should be steady. If you have a lot of fluctuation in the ping latency, then the network, workstation, or host can’t handle the traffic (or you are on a 4G network… )
- The internal network should be at 1ms with a max of 3ms.
- A good latency to a public server is in general between 7ms and 20ms.
C:\>ping lazyadmin.nl Pinging lazyadmin.nl [22.214.171.124] with 32 bytes of data: Reply from 126.96.36.199: bytes=32 time=10ms TTL=57 Reply from 188.8.131.52: bytes=32 time=11ms TTL=57 Reply from 184.108.40.206: bytes=32 time=11ms TTL=57 Reply from 220.127.116.11: bytes=32 time=10ms TTL=57 Ping statistics for 18.104.22.168: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 10ms, Maximum = 11ms, Average = 10ms
Take for example this site, which is hosted in the United States. If I ping it from my current location in the Netherlands, I have a ping of 10ms. Which is absolutely perfect.
If you have a high or inconsistent latency you really should check this article, where I talk more about optimizing your router to get the best performance.
Finding network issues with the Ping Cmd
If you have network issues your first start is probably to ping the server that you can’t reach. But that isn’t really helpful, yes you probably get the result Destination host unreachable but that doesn’t tell you much. Only that you can’t reach the server in question.
You want to know where the problem is, now you can ping each hop (network device) between you and the server, but there is a easier way. With pathping you can ping each hop between you and the server, showing you exactly where the connection is lost.
Read more about pathping and how to use it in this article.
Cmd ping Conclusion
Ping is a really easy-to-use command that is available on almost every device. Even some routers have built-in ping tools that you can use to troubleshoot your network. Keep an eye on the latency, that is one of the most important values from the ping cmd results.
If you have any questions, just drop a comment below!