Mastering the Ping Command: Testing Your Windows Network Connection

Explore the ins and outs of the ping command, uncovering how it ensures devices communicate effectively on your network

The Download

  • The ping command checks if one computer can talk to another on a network.
  • This command is used in Windows by sending messages to see if another computer replies.
  • You can ping a device using its name or IP address to test the connection.

The ping command is a Command Prompt command used to test whether your computer can reach another computer or network device. It's a straightforward way to ensure communication between devices.

How Does the Ping Command Work?

The ping command works by sending Internet Control Message Protocol (ICMP) Echo Request messages to the destination device and waiting for a reply. It shows how many responses are received and the time each one takes to return.

For instance, if a network printer doesn't respond to a ping, it might be offline or have a disconnected cable. You might also ping a router to confirm your computer can connect and rule it out as a network issue.

The word "ping" is also used online to refer to a brief message, usually over text or email. For example, you can "ping your boss" or send them a message about a project, but the ping command has nothing to do with it.

Ping Command Availability

The ping command is available from the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems. It's also available in older versions of Windows like Windows 98 and 95.

This command can also be found in Command Prompt in the Advanced Startup Options and System Recovery Options repair/recovery menus.

Ping command in Command Prompt on WIndows 10

Ping Command Syntax

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [-w timeout] [-R] [-S srcaddr] [-p] [-4] [-6] target [/?]

The availability of certain ping command switches and other ping command syntax might differ depending on the operating system.

Ping Command Options
Item Explanation
-t Use this option to ping the target continuously until stopped with Ctrl+C.
-a This option resolves the hostname of an IP address target, if possible.
-n count This sets the number of ICMP Echo Requests to send, ranging from 1 to 4294967295. By default, 4 requests are sent.
-l size Specify the size, in bytes, of the echo request packet, from 32 to 65,527. If not specified, the default size is 32 bytes.
-f Prevents ICMP Echo Requests from being fragmented by routers between you and the target. This is often used to troubleshoot Path Maximum Transmission Unit (PMTU) issues.
-i TTL Sets the Time to Live (TTL) value, with a maximum of 255.
-v TOS Allows setting a Type of Service (TOS) value. This option is obsolete starting with Windows 7 but remains for compatibility.
-r count Specifies the number of hops between your computer and the target to be recorded and displayed, with a maximum of 9. For more hop details, use the tracert command.
-s count Reports the time each echo request is received and each echo reply is sent, timestamped in Internet Format. Only the first four hops can be timestamped.
-w timeout Adjusts the timeout in milliseconds for each reply. The default is 4,000 milliseconds (4 seconds).
-R Commands the ping to trace the round-trip path..
-S srcaddr Specifies the source address.
-p Use this switch to ping a Hyper-V Network Virtualization provider address.
-4 Forces the ping command to use IPv4. This is only necessary when the target is a hostname.
-6 Forces the ping command to use IPv6, similar to -4, necessary for hostnames.
target This is the destination IP address or hostname you wish to ping.
/? Use the help switch to see detailed help about these options.

The -f-v-r-s-j, and -k options are applicable only for IPv4 addresses. The -R and -S options function only with IPv6.

Other less-used switches are available, including [-j host-list], [-k host-list], and [-c compartment]. Run ping /? In the Command Prompt for additional details.

You can save the ping command output to a file using a redirection operator.

Ping Command Examples

Below are several examples of commands that use ping.

Ping Google.com

 ping -n 5 -l 1500 www.google.com

In this example, the ping command is used to ping the hostname www.google.com. The -n option tells the ping command to send 5 ICMP Echo Requests instead of the default of 4, and the -l option sets the packet size for each request to 1500 bytes instead of the default of 32 bytes.

The result displayed in the Command Prompt window will look something like this:

 Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=29ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=30ms TTL=54
Reply from 172.217.1.142: bytes=1500 time=31ms TTL=54
Ping statistics for 172.217.1.142:
Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 31ms, Average = 30ms

The 0% loss reported under Ping statistics for 74.217.1.142 explains that each ICMP Echo Request message sent to www.google.com was returned. This means that, as far as this network connection goes, it can communicate with Google's website just fine.

Ping localhost

 ping 127.0.0.1

In the above example, we're pinging 127.0.0.1, also called the IPv4 localhost IP address or IPv4 loopback IP address, without options.

Using the ping command with this address is an excellent way to test that Windows' network features are working properly but it says nothing about your own network hardware or your connection to any other computer or device. The IPv6 version of this test would be ping ::1.

Find Hostname With Ping

 ping -a 192.168.1.22

In this example, we're asking the ping command to find the hostname assigned to the 192.168.1.22 IP address, but to otherwise ping it as normal.

The command might resolve the IP address, 192.168.1.22, as the hostname J3RTY22, for example, and then execute the remainder of the ping with default settings.

Ping Router Command

 ping 192.168.2.1

Similar to the other ping command examples, you can use this one to check if your computer can reach your router. The difference here is that instead of using a ping command switch or pinging the localhost, you'll be checking the connection between your computer and the router (here, 192.168.2.1).

If you're having trouble logging in to your router or accessing the internet, check if your router is accessible with this ping command. Be sure to replace 192.168.2.1 with your router's IP address.

Ping With IPv6

 ping -t -6 SERVER

In this example, you force the ping command to use IPv6 with the -6 option and continue pinging SERVER indefinitely with the -t option. You can interrupt the ping manually using Ctrl+C.

The number after the % in the replies from this ping command is the IPv6 Zone ID, which usually indicates the network interface used. To see a table of Zone IDs and their corresponding network interface names, execute netsh interface ipv6 show interface. The IPv6 Zone ID is found in the Idx column.

Ping Related Commands

You often use the ping command alongside other networking-related Command Prompt commands like tracert, ipconfignetstat, and nslookup.

Other Ping Uses

As shown above, you can also use the ping command to find a website's IP address. Follow the link to learn more about how to do this.

You can use ping on a Linux computer too, and third-party ping tools exist that offer more features than the basic ping command.

Frequently Asked Questions

Was this page helpful?

Related Articles