Config Server Firewall

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

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.

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