Pinging tests a connection to a device or network
The ping command is a Command Prompt command used to test the ability of the source computer to reach a specified destination computer. It’s a simple way to verify that a computer can communicate with another computer or network device.
How Does the Ping Command Work?
The ping command operates by sending Internet Control Message Protocol (ICMP) Echo Request messages to the destination computer and waiting for a response. The two major pieces of information that the ping command provides are how many of those responses are returned and how long it takes for them to return.
For example, you might find no responses when pinging a network printer, only to find out that the printer is offline and its cable needs replaced. Or maybe you need to ping a router to verify that your computer can connect to it to eliminate it as a possible cause for a networking issue.
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/06/Light_Bulb.jpg?resize=94%2C95&ssl=1)
Note
- 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.
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2023/12/ping-command-prompt.webp?resize=640%2C427&ssl=1)
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 [/?]
Ping Command Options | |
---|---|
Item | Explanation |
-t | Using this option will ping the target until you force it to stop by using Ctrl+C. |
-a | This ping command option will resolve, if possible, the hostname of an IP address target. |
-n count | This option sets the number of ICMP Echo Requests to send, from 1 to 4294967295. The ping command will send 4 by default if -n isn’t used. |
-l size | Use this option to set the size, in bytes, of the echo request packet from 32 to 65,527. The ping command will send a 32-byte echo request if you don’t use the -l option. |
-f | Use this ping command option to prevent ICMP Echo Requests from being fragmented by routers between you and the target. The -f option is most often used to troubleshoot Path Maximum Transmission Unit (PMTU) issues. |
-i TTL | This option sets the Time to Live (TTL) value, the maximum of which is 255. |
-v TOS | This option allows you to set a Type of Service (TOS) value. Beginning in Windows 7, this option no longer functions but still exists for compatibility reasons. |
-r count | Use this ping command option to specify the number of hops between your computer and the target computer or device that you’d like to be recorded and displayed. The maximum value for count is 9, so use the tracert command instead if you’re interested in viewing all the hops between two devices. |
-s count | Use this option to report the time, in Internet Timestamp format, that each echo request is received and echo reply is sent. The maximum value for count is 4, meaning that only the first four hops can be time stamped. |
-w timeout | Specifying a timeout value when executing the ping command adjusts the amount of time, in milliseconds, that ping waits for each reply. If you don’t use the -w option, the default timeout value of 4000 is used, which is 4 seconds. |
-R | This option tells the ping command to trace the round trip path. |
-S srcaddr | Use this option to specify the source address. |
-p | Use this switch to ping a Hyper-V Network Virtualization provider address. |
-4 | This forces the ping command to use IPv4 only but is only necessary if target is a hostname and not an IP address. |
-6 | This forces the ping command to use IPv6 only but as with the -4 option, is only necessary when pinging a hostname. |
target | This is the destination you wish to ping, either an IP address or a hostname. |
/? | Use the help switch with the ping command to show detailed help about the command’s several options. |
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/06/Light_Bulb.jpg?resize=94%2C95&ssl=1)
NOTE:
- The -f, -v, -r, -s, -j, and -k options work when pinging IPv4 addresses only. The -R and -S options only work with IPv6.
Other less commonly used switches for the ping command exist including [-jhost-list], [-khost-list], and [-ccompartment]. Execute ping /? from the Command Prompt for more information on these options.
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.11 IP address, but to otherwise ping it as normal.
The command might resolve the IP address, 192.168.1.22, as the hostname Z8RTY11, for example, and then execute the remainder of the ping with default settings.
Ping Router Command
ping 192.168.2.1
Similar to the ping command examples above, this one is used to see if your computer can reach your router. The only difference here is that instead of using a ping command switch or pinging the localhost, we’re checking the connection between the computer and the router (192.168.2.1 in this case).
If you’re having trouble logging in to your router or accessing the internet at all, see if your router is accessible with this ping command, of course, replacing 192.168.2.1 with your router’s IP address.
Ping With IPv6
ping -t -6 SERVER
In this example, we force the ping command to use IPv6 with the -6 option and continue to ping SERVER indefinitely with the -t option. You can interrupt the ping manually with Ctrl+C.
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/06/Light_Bulb.jpg?resize=94%2C95&ssl=1)
TIP:
The number after the % in the replies generated in this ping command example is the IPv6 Zone ID, which most often indicates the network interface used. You can generate a table of Zone IDs matched with your network interface names by executing netsh interface ipv6 show interface. The IPv6 Zone ID is the number in the Idx column.
Ping Related Commands
The ping command is often used with other networking related Command Prompt commands like tracert, ipconfig, netstat, and nslookup.
![Nord VPN](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2020/10/NordVPN.jpg?resize=640%2C79&ssl=1)
![Coinbase - Getty Images - 1234552839](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/10/Coinbase_GettyImages-1234552839.webp?resize=640%2C360&ssl=1)
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2023/06/HA-TryHackMe-s.jpg?resize=640%2C305&ssl=1)
![Chase Sapphire Preferred - Travel Points](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2023/10/chase_sapphire_preferred-travel_points.png?resize=588%2C508&ssl=1)
![NordPass - Password Manager - CJ Banner](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/10/NordPass-Password_Manager-CJ_Banner.jpg?resize=640%2C78&ssl=1)
![Binance Cryptowallet - Buy/Sell](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/09/binance_web-1.jpg?resize=640%2C368&ssl=1)
![Amazon - Daily Deals](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/06/Amazon-Daily_Deals-1.jpg?resize=466%2C142&ssl=1)
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/10/grubhub_affliate_logo.jpg?resize=640%2C336&ssl=1)
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/10/idle_emprire.jpg?resize=500%2C261&ssl=1)
![](https://i0.wp.com/hideout.co/assets/img/referral_banners/hban1_728x90.png?w=640&ssl=1)
![](https://i0.wp.com/zpenterprises.co/wp-content/uploads/2022/12/Model_T_Unlock_static.webp?resize=639%2C780&ssl=1)