<p>The ping <a href="https://www.lifewire.com/what-is-a-command-2625828" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="1">command</a> is a <a href="https://www.lifewire.com/list-of-command-prompt-commands-4092302" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="2">Command Prompt command</a> used to test the ability of the source computer to reach a specified destination computer. The ping command is usually used as a simple way to verify that a computer can communicate over the network with another computer or network device.</p><p>The ping command operates by sending <em>Internet Control Message Protocol (ICMP) Echo Request</em> messages to the destination computer and waiting for a response. How many of those responses are returned, and how long it takes for them to return, are the two major pieces of information that the ping command provides.</p><p>For example, you might find that there are 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 <a href="https://www.lifewire.com/what-is-a-router-2618162" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="3">router</a> to verify that your computer can connect to it, to eliminate it as a possible cause for a networking issue.</p><h3>Ping Command Availability</h3><p>The ping command is available from within the <a href="https://www.lifewire.com/command-prompt-2625840" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="4">Command Prompt</a> in <a href="https://www.lifewire.com/windows-10-2626217" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="5">Windows 10</a>, <a href="https://www.lifewire.com/windows-8-2626235" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="6">Windows 8</a>, <a href="https://www.lifewire.com/windows-7-2626265" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="7">Windows 7</a>, <a href="https://www.lifewire.com/windows-vista-2626311" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="8">Windows Vista</a>, and <a href="https://www.lifewire.com/windows-xp-2626354" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="9">Windows XP</a> <a href="https://www.lifewire.com/operating-systems-2625912" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="10">operating systems</a>. The ping command is also available in older versions of Windows like Windows 98 and 95.</p><p>The ping command can also be found in Command Prompt in the <a href="https://www.lifewire.com/advanced-startup-options-2625805" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="11">Advanced Startup Options</a> and <a href="https://www.lifewire.com/system-recovery-options-2626021" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="12">System Recovery Options</a> repair/recovery menus.</p><p><strong>Note:</strong> The availability of certain ping command switches and other ping command <a href="https://www.lifewire.com/what-is-syntax-2626014" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="13">syntax</a> might differ from operating system to operating system.</p><h3>Ping Command Syntax</h3><p><strong>ping</strong> [<strong>-t</strong>] [<strong>-a</strong>] [<strong>-n</strong> <em>count</em>] [<strong>-l</strong> <em>size</em>] [<strong>-f</strong>] [<strong>-i</strong> <em>TTL</em>] [<strong>-v</strong> <em>TOS</em>] [<strong>-r</strong> <em>count</em>] [<strong>-s</strong> <em>count</em>] [<strong>-w</strong> <em>timeout</em>] [<strong>-R</strong>] [<strong>-S</strong> <em>srcaddr</em>] [<strong>-p</strong>] [<strong>-4</strong>] [<strong>-6</strong>] <em>target</em> [<strong>/?</strong>]</p><p><strong>Tip:</strong> See <a href="https://www.lifewire.com/how-to-read-command-syntax-2618082" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="14">How to Read Command Syntax</a> if you&#39;re not sure how to interpret the ping command syntax above or described in the table below.</p><table border="1" cellpadding="2" cellspacing="0"><tbody><tr><td width="20%"><strong>-t</strong></td><td>Using this option will ping the <em>target</em> until you force it to stop using <a href="https://www.lifewire.com/what-is-ctrl-c-used-for-2625834" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="15">Ctrl-C</a>.</td></tr><tr><td><strong>-a</strong></td><td>This ping command option will resolve, if possible, the <a href="https://www.lifewire.com/what-is-a-hostname-2625906" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="16">hostname</a> of an <a href="https://www.lifewire.com/what-is-an-ip-address-2625920" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="17">IP address</a> <em>target</em>.</td></tr><tr><td><strong>-n</strong> <em>count</em></td><td>This option sets the number of ICMP Echo Requests to send, from 1 to 4294967295. The ping command will send 4 by default if <strong>-n</strong> isn&#39;t used.</td></tr><tr><td><strong>-l</strong> <em>size</em></td><td>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&#39;t use the <strong>-l</strong> option.</td></tr><tr><td><strong>-f</strong></td><td>Use this ping command option to prevent ICMP Echo Requests from being fragmented by routers between you and the <em>target</em>. The <strong>-f</strong> option is most often used to troubleshoot Path Maximum Transmission Unit (PMTU) issues.</td></tr><tr><td><strong>-i</strong> <em>TTL</em></td><td>This option sets the Time to Live (TTL) value, the maximum of which is 255.</td></tr><tr><td><strong>-v</strong> <em>TOS</em></td><td>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.</td></tr><tr><td><strong>-r</strong> <em>count</em></td><td>Use this ping command option to specify the number of <a href="https://www.lifewire.com/what-are-hops-hop-counts-2625905" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="18">hops</a> between your computer and the <em>target</em> computer or device that you&#39;d like to be recorded and displayed. The maximum value for <em>count</em> is 9, so use the <a href="https://www.lifewire.com/tracert-command-2618101" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="19">tracert command</a> instead if you&#39;re interested in viewing all the hops between two devices.</td></tr><tr><td><strong>-s</strong> <em>count</em></td><td>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 <em>count</em> is 4, meaning that only the first four hops can be time stamped.</td></tr><tr><td><strong>-w</strong> <em>timeout</em></td><td>Specifying a <em>timeout</em> value when executing the ping command adjusts the amount of time, in milliseconds, that ping waits for each reply. If you don&#39;t use the <strong>-w</strong> option, the default timeout value of 4000 is used, which is 4 seconds.</td></tr><tr><td><strong>-R</strong></td><td>This option tells the ping command to trace the round trip path.</td></tr><tr><td><strong>-S</strong> <em>srcaddr</em></td><td>Use this option to specify the source address.</td></tr><tr><td><strong>-p</strong></td><td>Use this switch to ping a <em>Hyper-V Network Virtualization</em> provider address.</td></tr><tr><td><strong>-4</strong></td><td>This forces the ping command to use IPv4 only but is only necessary if <em>target</em> is a hostname and not an IP address.</td></tr><tr><td><strong>-6</strong></td><td>This forces the ping command to use IPv6 only but as with the <strong>-4</strong> option, is only necessary when pinging a hostname.</td></tr><tr><td><em>target</em></td><td>This is the destination you wish to ping, either an IP address or a hostname.</td></tr><tr><td><strong>/?</strong></td><td>Use the <a href="https://www.lifewire.com/help-switch-2625896" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="20">help switch</a> with the ping command to show detailed help about the command&#39;s several options.</td></tr></tbody></table><p><strong>Note:</strong> The <strong>-f</strong>, <strong>-v</strong>, <strong>-r</strong>, <strong>-s</strong>, <strong>-j</strong>, and <strong>-k</strong> options work when pinging IPv4 addresses only. The <strong>-R</strong> and <strong>-S</strong> options only work with IPv6.</p><p>Other less commonly used switches for the ping command exist including [<strong>-j</strong> <em>host-list</em>], [<strong>-k</strong> <em>host-list</em>], and [<strong>-c</strong> <em>compartment</em>]. Execute <strong>ping /?</strong> from the Command Prompt for more information on these two options.</p><p><strong>Tip:</strong> Save all of the ping command output to a file using a <a href="https://www.lifewire.com/redirection-operator-2625979" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="21">redirection operator</a>. See <a href="https://www.lifewire.com/how-to-redirect-command-output-to-a-file-2618084" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="22">How to Redirect Command Output to a File</a> for instructions or see our <a href="https://www.lifewire.com/command-prompt-tricks-and-hacks-2618104" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="23">Command Prompt Tricks</a> list for more tips.</p><h3>Ping Command Examples</h3><pre> <strong>ping -n 5 -l 1500 www.google.com</strong> </pre><p>In this example, the ping command is used to ping the hostname <em>www.google.com</em>. The <strong>-n</strong> option tells the ping command to send <em>5</em> ICMP Echo Requests instead of the default of 4, and the <strong>-l</strong> option sets the packet size for each request to <em>1500</em> bytes instead of the default of 32 bytes.</p><p>The result displayed in the Command Prompt window will look something like this:</p><pre> <code>Pinging www.google.com [74.125.224.82] with 1500 bytes of data: Reply from 74.125.224.82: bytes&#61;1500 time&#61;68ms TTL&#61;52 Reply from 74.125.224.82: bytes&#61;1500 time&#61;68ms TTL&#61;52 Reply from 74.125.224.82: bytes&#61;1500 time&#61;65ms TTL&#61;52 Reply from 74.125.224.82: bytes&#61;1500 time&#61;66ms TTL&#61;52 Reply from 74.125.224.82: bytes&#61;1500 time&#61;70ms TTL&#61;52 Ping statistics for 74.125.224.82: Packets: Sent &#61; 5, Received &#61; 5, Lost &#61; 0 (0% loss), Approximate round trip times in milli-seconds: Minimum &#61; 65ms, Maximum &#61; 70ms, Average &#61; 67ms</code> </pre><p>The <em>0% loss</em> reported under <em>Ping statistics for 74.125.224.82</em> tells me that each ICMP Echo Request message sent to <em>www.google.com</em> was returned. This means that, as far as my network connection goes, I can communicate with Google&#39;s website just fine.</p><pre> <strong>ping 127.0.0.1</strong> </pre><p>In the above example, I&#39;m pinging <em>127.0.0.1</em>, also called the IPv4 localhost IP address or IPv4 loopback IP address, without options.</p><p>Using the ping command to ping <em>127.0.0.1</em> is an excellent way to test that Windows&#39; network features are working properly but it says nothing about your own network <a href="https://www.lifewire.com/computer-hardware-2625895" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="24">hardware</a> or your connection to any other computer or device. The IPv6 version of this test would be <strong>ping ::1</strong>.</p><pre> <strong>ping -a 192.168.1.22</strong> </pre><p>In this example I&#39;m asking the ping command to find the hostname assigned to the <em>192.168.1.22</em> IP address, but to otherwise ping it as normal.</p><pre> <code>Pinging J3RTY22 [192.168.1.22] with 32 bytes of data: Reply from 192.168.1.22: bytes&#61;32 time </code></pre><p>As you can see, the ping command resolved the IP address I entered, <em>192.168.1.22</em>, as the hostname <em>J3RTY22</em>, and then executed the remainder of the ping with default settings.</p><pre> <strong>ping -t -6 SERVER</strong> </pre><p>In this example, I force the ping command to use IPv6 with the <strong>-6</strong> option and continue to ping <em>SERVER</em> indefinitely with the <strong>-t</strong> option.</p><pre> <code>Pinging SERVER [fe80::fd1a:3327:2937:7df3%10] with 32 bytes of data: Reply from fe80::fd1a:3327:2937:7df3%10: time&#61;1ms Reply from fe80::fd1a:3327:2937:7df3%10: time </code></pre><p>I interrupted the ping manually with Ctrl-C after seven replies. Also, as you can see, the <strong>-6</strong> option produced IPv6 addresses.</p><p><strong>Tip:</strong> 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 <strong>netsh interface ipv6 show interface</strong>. The IPv6 Zone ID is the number in the <em>Idx</em> column.</p><h3>Ping Related Commands</h3><p>The ping command is often used with other networking related Command Prompt commands like <a href="https://www.lifewire.com/tracert-command-2618101" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="25">tracert</a>, ipconfig, <a href="https://www.lifewire.com/netstat-command-2618098" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="26">netstat</a>, nslookup, and others.</p>