Using the Ping Command

Applies To: Windows Server 2008

The ping command helps to verify IP-level connectivity. When troubleshooting, you can use ping to send an ICMP echo request to a target host name or IP address. Use ping whenever you need to verify that a host computer can connect to the TCP/IP network and network resources. You can also use ping to isolate network hardware problems and incompatible configurations.

Follow this sequence to diagnose network connectivity:

  1. Ping the loopback address to verify that TCP/IP is configured correctly on the local computer.

    ping 127.0.0.1

  2. Ping the IP address of the local computer to verify that it was added to the network correctly.

    ping IP_address_of_local_host

  3. Ping the IP address of the default gateway to verify that the default gateway is functioning and that you can communicate with a local host on the local network.

    ping IP_address_of_default_gateway

  4. Ping the IP address of a remote host to verify that you can communicate through a router.

    ping IP_address_of_remote_host

The following table shows some useful ping command options.

Option Use

-n Count

Determines the number of echo requests to send. The default is 4 requests.

-w Timeout

Enables you to adjust the timeout (in milliseconds). The default is 4,000 (a 4-second timeout).

-l Size

Enables you to adjust the size of the ping packet. The default size is 32 bytes.

-f

Sets the Do Not Fragment bit on the ping packet. By default, the ping packet allows fragmentation.

/?

Provides command Help.

The following example illustrates how to send two pings, each 1,450 bytes in size, to IP address 131.107.8.1:

C:\>ping -n 2 -l 1450 131.107.8.1
Pinging 131.107.8.1 with 1450 bytes of data:

Reply from 131.107.8.1: bytes=1450 time<10ms TTL=32
Reply from 131.107.8.1: bytes=1450 time<10ms TTL=32

Ping statistics for 131.107.8.1:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate roundtrip times in milliseconds:
    Minimum = 0ms, Maximum =  10ms, Average =  2ms

By default, ping waits 4,000 milliseconds (4 seconds) for each response to be returned before displaying the "Request Timed Out" message. If the remote system being pinged is across a high-delay link, such as a satellite link, responses might take longer to be returned. You can use the -w (wait) option to specify a longer timeout.

A response of "Destination net unreachable" means there was no route to the destination. You need to check the routing table on the router listed in the "Reply from" address in the "Destination net unreachable" message. For more information about the routing table, see Manage the IPv4 Routing Table.

A response of "Request timed out" means that there was no response to the ping in the default time period (1 second). You can check for the following:

  • The ping command is blocked at the corporate or personal firewall level.

    Configure the corporate firewall to allow the ping command network access. Configure the personal firewall to allow ICMP Echo and Echo Reply packets.

  • A router is down.

    To check the routers in the path between the source and the destination, use the tracert command.

  • The destination host is down.

    Physically verify that the host is running or check connectivity through another protocol.

  • There is no route back to your computer.

    If the host is running, you can check for a return route by viewing the default gateway and local routing table on the destination host.

  • The latency of the response is more than one second.

    Use the -w option on the ping command to increase the timeout. For example, to allow responses within 5 seconds, use ping-w 5000.

The ping command uses Windows Sockets-style name resolution to resolve a computer name to an IP address, so if pinging by address succeeds, but pinging by name fails, then the problem lies in address or name resolution, not network connectivity.