pingping

适用于: Windows Server (半年通道) ,Windows Server 2019,Windows Server 2016,Windows Server 2012 R2,Windows Server 2012Applies to: Windows Server (Semi-Annual Channel), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012

通过向另一台 TCP/IP 计算机发送 Internet 控制消息协议 (ICMP) 回响请求消息来验证 IP 级连接。Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) echo Request messages. 将显示相应的回响回复消息以及往返时间。The receipt of corresponding echo Reply messages are displayed, along with round-trip times. ping 是用于排查连接性、可访问性和名称解析的主要 TCP/IP 命令。ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. 使用没有参数的情况下,此命令显示帮助内容。Used without parameters, this command displays Help content.

你还可以使用此命令测试计算机的计算机名和 IP 地址。You can also use this command to test both the computer name and the IP address of the computer. 如果成功完成了 IP 地址的 ping 操作,但不对计算机名称进行 ping 操作,则可能存在名称解析问题。If pinging the IP address is successful, but pinging the computer name isn't, you might have a name resolution problem. 在这种情况下,请确保你指定的计算机名可以通过本地主机文件进行解析,方法是使用域名系统 (DNS) 查询,或通过 NetBIOS 名称解析技术。In this case, make sure that the computer name you are specifying can be resolved through the local Hosts file, by using Domain Name System (DNS) queries, or through NetBIOS name resolution techniques.

备注

仅当在 "网络连接" 中网络适配器的属性中将 "Internet 协议" (TCP/IP) 协议安装为组件时,此命令才可用。This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections.

语法Syntax

ping [/t] [/a] [/n <count>] [/l <size>] [/f] [/I <TTL>] [/v <TOS>] [/r <count>] [/s <count>] [{/j <hostlist> | /k <hostlist>}] [/w <timeout>] [/R] [/S <Srcaddr>] [/4] [/6] <targetname>

参数Parameters

参数Parameter 说明Description
/t /t 指定 ping 继续向目标发送回显请求消息,直到中断。Specifies that ping continue sending echo Request messages to the destination until interrupted. 若要中断和显示统计信息,请按 CTRL + ENTER。To interrupt and display statistics, press CTRL+ENTER. 若要中断并退出此命令,请按 CTRL + C。To interrupt and quit this command, press CTRL+C.
/a/a 指定对目标 IP 地址执行反向名称解析。Specifies that reverse name resolution is performed on the destination IP address. 如果此操作成功,则 ping 将显示相应的主机名。If this is successful, ping displays the corresponding host name.
/n <count>/n <count> 指定发送的回送请求消息数。Specifies the number of echo Request messages sent. 默认值为 4。The default is 4.
/l <size>/l <size> 指定发送的回响请求消息中的 数据 字段的长度(以字节为单位)。Specifies the length, in bytes, of the Data field in the echo Request messages sent. 默认值为 32。The default is 32. 最大大小为65527。The maximum size is 65,527.
/f/f 指定发送回显请求消息时,如果 IP 标头中的 " 不分段 " 标志设置为1,则在 IPv4 上仅) 可用 (。Specifies that echo Request messages are sent with the Do not Fragment flag in the IP header set to 1 (available on IPv4 only). 目标的路径中的路由器无法对 echo 请求消息进行分段。The echo Request message can't be fragmented by routers in the path to the destination. 此参数可用于排查路径最大传输单元 (PMTU) 问题。This parameter is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems.
/I <TTL>/I <TTL> 指定发送的回响请求消息的 IP 标头中的 TTL 字段的值。Specifies the value of the TTL field in the IP header for echo Request messages sent. 默认值为主机的默认 TTL 值。The default is the default TTL value for the host. 最大 TTL 为255。The maximum TTL is 255.
/v <TOS>/v <TOS> 为) (发送的回响请求消息的 IP 标头中的服务 (TOS) 字段指定类型的值。Specifies the value of the type of Service (TOS) field in the IP header for echo Request messages sent (available on IPv4 only). 默认值为 0。The default is 0. TOS 指定为介于0到255之间的十进制值。TOS is specified as a decimal value from 0 through 255.
/r <count>/r <count> 指定 IP 标头中的 记录路由 选项用于记录回显请求消息所采用的路径,以及相应的回显回复消息 (仅在 IPv4 上提供) 。Specifies that the Record Route option in the IP header is used to record the path taken by the echo Request message and corresponding echo Reply message (available on IPv4 only). 路径中的每个跃点都使用 记录路由 选项中的条目。Each hop in the path uses an entry in the Record Route option. 如果可能,请指定等于或大于源和目标之间的跃点数的 计数If possible, specify a count that's equal to or greater than the number of hops between the source and destination. 计数的最小值必须为1,最大值为9。The count must be a minimum of 1 and a maximum of 9.
/s <count>/s <count> 指定 IP 标头中的 Internet 时间戳 选项用于记录每个跃点的回显请求消息到达的时间和相应的回显答复消息。Specifies that the Internet timestamp option in the IP header is used to record the time of arrival for the echo Request message and corresponding echo Reply message for each hop. 计数的最小值必须为1,最大值为4。The count must be a minimum of 1 and a maximum of 4. 这对于链接本地目标地址是必需的。This is required for link-local destination addresses.
/j <hostlist>/j <hostlist> 指定回显请求消息使用 IP 标头中的 " 松散源路由 " 选项,其中包含 hostlist 中指定的中间目标集, (仅在 IPv4 上提供) 。Specifies that the echo Request messages use the Loose Source Route option in the IP header with the set of intermediate destinations specified in hostlist (available on IPv4 only). 使用松散源路由时,可通过一个或多个路由器分隔连续的中间目标。With loose source routing, successive intermediate destinations can be separated by one or multiple routers. 主机列表中的最大地址或名称数为9。The maximum number of addresses or names in the host list is 9. 主机列表是一系列以点分隔的十进制表示法 (的 IP 地址,) 用空格分隔。The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.
遇到 <hostlist>/k <hostlist> 指定回显请求消息使用 IP 标头中的 " 严格源路由 " 选项,其中包含 hostlist 中指定的中间目标集, (仅在 IPv4 上提供) 。Specifies that the echo Request messages use the Strict Source Route option in the IP header with the set of intermediate destinations specified in hostlist (available on IPv4 only). 使用严格源路由时,下一个中间目标必须是直接可访问的 (它必须是路由器的接口) 上的邻居。With strict source routing, the next intermediate destination must be directly reachable (it must be a neighbor on an interface of the router). 主机列表中的最大地址或名称数为9。The maximum number of addresses or names in the host list is 9. 主机列表是一系列以点分隔的十进制表示法 (的 IP 地址,) 用空格分隔。The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.
/w <timeout>/w <timeout> 指定等待回送答复消息的时间量(以毫秒为单位),该消息对应于要接收的给定回响请求消息。Specifies the amount of time, in milliseconds, to wait for the echo Reply message that corresponds to a given echo Request message to be received. 如果在超时时间内未收到回显回复消息,则会显示 "请求超时" 错误消息。If the echo Reply message is not received within the time-out, the "Request timed out" error message is displayed. 默认超时为 4000 (4 秒) 。The default time-out is 4000 (4 seconds).
/R/R 指定仅) 在 IPv6 上跟踪往返路径 (。Specifies that the round-trip path is traced (available on IPv6 only).
/S <Srcaddr>/S <Srcaddr> 指定要使用的源地址 (仅) 上可用的 IPv6。Specifies the source address to use (available on IPv6 only).
/4/4 指定使用 IPv4 进行 ping 操作。Specifies that IPv4 is used to ping. 使用 IPv4 地址标识目标主机时不需要此参数。This parameter is not required to identify the target host with an IPv4 address. 只需按名称标识目标主机即可。It is only required to identify the target host by name.
/6/6 指定使用 IPv6 来进行 ping 操作。Specifies that IPv6 is used to ping. 使用 IPv6 地址标识目标主机时不需要此参数。This parameter is not required to identify the target host with an IPv6 address. 只需按名称标识目标主机即可。It is only required to identify the target host by name.
<targetname> 指定目标的主机名或 IP 地址。Specifies the host name or IP address of the destination.
/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

Ping 命令输出示例Example of the ping command output

C:\>ping example.microsoft.com
    pinging example.microsoft.com [192.168.239.132] with 32 bytes of data:
    Reply from 192.168.239.132: bytes=32 time=101ms TTL=124
    Reply from 192.168.239.132: bytes=32 time=100ms TTL=124
    Reply from 192.168.239.132: bytes=32 time=120ms TTL=124
    Reply from 192.168.239.132: bytes=32 time=120ms TTL=124

示例Examples

若要 ping 目标10.0.99.221 并解析10.0.99.221 的主机名,请键入:To ping the destination 10.0.99.221 and resolve 10.0.99.221 to its host name, type:

ping /a 10.0.99.221

若要使用10个回响请求消息 ping 目标10.0.99.221,其中每个请求消息的数据字段为1000字节,请键入:To ping the destination 10.0.99.221 with 10 echo Request messages, each of which has a Data field of 1000 bytes, type:

ping /n 10 /l 1000 10.0.99.221

若要 ping 目标10.0.99.221 并记录4个跃点的路由,请键入:To ping the destination 10.0.99.221 and record the route for 4 hops, type:

ping /r 4 10.0.99.221

若要 ping 目标10.0.99.221 并指定 10.12.0.1-10.29.3.1-10.1.44.1 的稀疏源路由,请键入:To ping the destination 10.0.99.221 and specify the loose source route of 10.12.0.1-10.29.3.1-10.1.44.1, type:

ping /j 10.12.0.1 10.29.3.1 10.1.44.1 10.0.99.221

其他参考Additional References