CMD Ping Command | Test Network Connectivity and Latency

CMD Ping Command

The ping command sends ICMP requests, also known as pings, to a remote device and returns the response. It is the most popular command-line tool for testing connectivity between two network devices.

To do a ping test, execute the command followed by the IP Address or domain name of the remote host you want to test.

ping 192.168.1.1
ping example.com
  • By default, the CMD ping command sends out 4 ICMP echo-request packets.
  • With the -n option, you can specify the number of echo requests to send.
  • If you use the -t option, it sends continuous pings until you stop the command by pressing the Ctrl+C key sequence.

Examples

Ping the IP Address of the remote host:

ping 192.168.1.1

Ping the domain name of the remote host:

ping example.com

We can specify the ping count with the -n option:

ping -n 10 192.168.1.1

In the following example, we use the -t option to send continuous pings to the IP Address 192.168.1.1 (you stop the command by pressing Ctrl+C):

ping -t 192.168.1.1

Ping the Google DNS Server:

ping 8.8.8.8

Ping the Google DNS Server from the source IP Address 192.168.1.20:

ping -S 192.168.1.20 192.168.1.1

Ping a remote computer with a larger packet size:

ping -l 1000 192.168.1.1

This command resolves the IP address to the hostname before sending echo requests:

ping -a 8.8.8.8

Command Options

-tUse this option to send continuous pings. To stop the test, press Control + C.
-nUse this option to specify the number of pings to send. The default is 4.
-aResolve addresses to hostnames (reverse DNS lookup) if possible.
-iUse this option to specify the TTL (Time to live) value. TTL tells the maximum number of routers each ICMP packet may pass through on its way to a destination.
-lUse this option to modify the packet size of the ICMP Echo Request. The default is 32 bytes.
-wTimeout in milliseconds to wait for each reply.
-SWhen your computer has more than one IP address, use this option to specify the source IP address from which the pings should be sent.
/?This option displays the help file for the CMD ping command.

The ping command tests connectivity between two network devices by sending an ICMP Echo Request to the remote device. If the remote device receives the request, it sends an ICMP Echo Reply confirming the connectivity.

If the ping is successful, you will see the ICMP Echo Reply from the remote IP, as shown in the following screenshot.

Windows Ping command

Under the statistics section, you will see the number of packets that were sent, received, and lost.

When the ping command fails, you will get one of several error messages like Destination host unreachable or Request timed out.

  • Destination host unreachable - No routes to the destination. Your router does not know how to reach the remote computer you specified.
  • Ping request could not find host - This is a DNS error. Your DNS Server can't resolve the domain name to the IP address. You probably entered an incorrect domain name.
  • Request timed out - Your computer did not receive ICMP Echo Reply from the targeted device. This doesn't necessarily mean that the host is down. It might be because the remote computer blocks pings.

Continuous Ping Command

The -t is the continuous ping command option. It sends ICMP Echo Requests to the remote computer until you manually stop the command by pressing Ctrl + C.

Continuous Ping Command
Continuous Ping Command

You can view the statistics while the test is running by pressing Ctrl + Pause key combination.

cmd ping statistics

The -n option allows you to specify the number of pings to send. The Windows default is 4 ICMP requests.

ping count

Using ping to Check Internet Connection

Ping is an excellent command-line tool to test your internet connection on Windows. The following steps illustrate the process.

  1. Ping the loopback address 127.0.0.1 to ensure there is nothing wrong with the TCP/IP stack.
  2. Next, ping the IPv4 address of the local network interface. If it is successful, you know that the local network interface is functioning.
  3. Next, Ping the IP address of the default gateway. Ensure you have connectivity to the gateway.
  4. Next, Ping an IP Address on the Internet. A good reliable one is 8.8.8.8. The test is successful means you have a connection to the internet. If not, the problem is with your router.
  5. Finally, Ping an Internet domain name like google.com or example.com. If this succeeds, everything is working. If not, the problem is with the DNS.

You can view the IP configuration of your local Windows system by running the ipconfig /all command.

ipconfig command
ipconfig command

Remarks

  • A Firewall can block pings. So you may not get a reply from the remote device even if it is up and running.
  • The Firewall on Windows 10/11 blocks pings (ICMP) out of the box. You can click on this link to learn how to allow ping through Windows Firewall.
  • The PowerShell equivalent to the ping is the Test-NetConnection cmdlet; Ping is still available.
  • While working on the command prompt, type ping /? to see a list of all command options.