CMD Ping, one of the most used commands by IT professionals to test the network. With the ping command, 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 CMD Ping 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 test cmd
You can use the ping command from every terminal, like Command Prompt, PowerShell, or in the terminal on Linux or macOS.
- Press the Windows Key + X or Right Click on the start menu
- Select either Command Prompt or Windows PowerShell
- Type Ping followed by the IP Address of the device you want to ping.
For example, if you want to test your connection to the internet, type: ping 188.8.131.52.
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 have a good wireless network connection.
The first thing we do is to 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 to 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 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 succesvol connection to the router. All the package 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 184.108.40.206.
# Ping Google cmd ping 220.127.116.11
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 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 of WiFi or cable? What kind of internet connection do you have? Where are you located compared to the host geographically?
Their are a few general guide lines 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 [18.104.22.168] with 32 bytes of data: Reply from 22.214.171.124: bytes=32 time=10ms TTL=57 Reply from 126.96.36.199: bytes=32 time=11ms TTL=57 Reply from 188.8.131.52: bytes=32 time=11ms TTL=57 Reply from 184.108.40.206: bytes=32 time=10ms TTL=57 Ping statistics for 220.127.116.11: 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.
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.
Continuous Ping CMD – Ping -t
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 can 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.
Increase package size – Ping -l
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.
Number of Pings – Ping -n
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
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.