CMD Ping Command | Test Network Connectivity and Latency
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.
- By default, the CMD
pingcommand sends out 4 ICMP echo-request packets.
- With the
-noption, you can specify the number of echo requests to send.
- If you use the
-toption, it sends continuous pings until you stop the command by pressing the
Ping the IP Address of the remote host:
Ping the domain name of the remote host:
We can specify the ping count with the
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
ping -t 192.168.1.1
Ping the Google DNS Server:
Ping the Google DNS Server from the source IP Address
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 184.108.40.206
|Use this option to send continuous pings. To stop the test, press
Control + C.
|Use this option to specify the number of pings to send. The default is 4.
|Resolve addresses to hostnames (reverse DNS lookup) if possible.
|Use 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.
|Use this option to modify the packet size of the ICMP Echo Request. The default is 32 bytes.
|Timeout in milliseconds to wait for each reply.
|When 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.
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.
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
-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.
You can view the statistics while the test is running by pressing
Ctrl + Pause key combination.
-n option allows you to specify the number of pings to send. The Windows default is 4 ICMP requests.
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.
- Ping the loopback address
127.0.0.1to ensure there is nothing wrong with the TCP/IP stack.
- Next, ping the IPv4 address of the local network interface. If it is successful, you know that the local network interface is functioning.
- Next, Ping the IP address of the default gateway. Ensure you have connectivity to the gateway.
- Next, Ping an IP Address on the Internet. A good reliable one is
220.127.116.11. The test is successful means you have a connection to the internet. If not, the problem is with your router.
- Finally, Ping an Internet domain name like
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.
- 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-NetConnectioncmdlet; Ping is still available.
- While working on the command prompt, type
ping /?to see a list of all command options.