
The ping command operates by sending Internet Control Message Protocol (ICMP) Echo Request
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.
ping /?
C:\tmp>ping /?
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] [-R] [-S srcaddr] [-c compartment] [-p]
[-4] [-6] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP
Header).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host-list Loose source route along host-list (IPv4-only).
-k host-list Strict source route along host-list (IPv4-only).
-w timeout Timeout in milliseconds to wait for each reply.
-R Use routing header to test reverse route also (IPv6-only).
Per RFC 5095 the use of this routing header has been
deprecated. Some systems may drop echo requests if
this header is used.
-S srcaddr Source address to use.
-c compartment Routing compartment identifier.
-p Ping a Hyper-V Network Virtualization provider address.
-4 Force using IPv4.
-6 Force using IPv6.
C:\tmp>
1. Basic Usage
C:\tmp>ping google.ca
Pinging google.ca [216.58.192.195] with 32 bytes of data:
Reply from 216.58.192.195: bytes=32 time=33ms TTL=50
Reply from 216.58.192.195: bytes=32 time=33ms TTL=50
Reply from 216.58.192.195: bytes=32 time=33ms TTL=50
Reply from 216.58.192.195: bytes=32 time=33ms TTL=50
Ping statistics for 216.58.192.195:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 33ms, Maximum = 33ms, Average = 33ms
C:\tmp>
2. Ping -t
C:\tmp>ping www.google.ca -t
Pinging www.google.ca [216.58.192.131] with 32 bytes of data:
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=34ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Ping statistics for 216.58.192.131:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 33ms, Maximum = 34ms, Average = 33ms
Control-C
^C
C:\tmp>
3. Ping -a
C:\tmp>ping -a 192.168.2.200
Pinging HMNHD-TI2REA [192.168.2.200] with 32 bytes of data:
Reply from 192.168.2.200: bytes=32 time=1ms TTL=63
Reply from 192.168.2.200: bytes=32 time=1ms TTL=63
Reply from 192.168.2.200: bytes=32 time=1ms TTL=63
Reply from 192.168.2.200: bytes=32 time=2ms TTL=63
Ping statistics for 192.168.2.200:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\tmp>
4. ping -n
C:\tmp>ping -n 10 www.google.ca
Pinging www.google.ca [216.58.192.131] with 32 bytes of data:
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=32ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Reply from 216.58.192.131: bytes=32 time=33ms TTL=50
Ping statistics for 216.58.192.131:
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 32ms, Maximum = 33ms, Average = 32ms
5. ping -l size
C:\tmp>ping -l 35500 www.51sec.org
Pinging www.51sec.org [104.24.116.167] with 35500 bytes of data:
Reply from 104.24.116.167: bytes=35500 time=120ms TTL=55
Reply from 104.24.116.167: bytes=35500 time=121ms TTL=55
Reply from 104.24.116.167: bytes=35500 time=119ms TTL=55
Reply from 104.24.116.167: bytes=35500 time=120ms TTL=55
Ping statistics for 104.24.116.167:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 119ms, Maximum = 121ms, Average = 120ms
C:\tmp>ping -n 5 -l 1500 www.51sec.org
Pinging www.51sec.org [104.24.116.167] with 1500 bytes of data:
Reply from 104.24.116.167: bytes=1500 time=37ms TTL=55
Reply from 104.24.116.167: bytes=1500 time=37ms TTL=55
Reply from 104.24.116.167: bytes=1500 time=37ms TTL=55
Reply from 104.24.116.167: bytes=1500 time=37ms TTL=55
Reply from 104.24.116.167: bytes=1500 time=37ms TTL=55
Ping statistics for 104.24.116.167:
Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 37ms, Maximum = 37ms, Average = 37ms
C:\tmp>
6. Ping -f
C:\tmp>ping -f -l 1500 www.51sec.org
Pinging www.51sec.org [104.24.117.167] with 1500 bytes of data:
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Ping statistics for 104.24.117.167:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
C:\tmp>
7. Ping whole network
C:\tmp>for /L %D in (1,1,255) do ping 10.94.200.%D
C:\tmp>ping 10.94.200.1
Pinging 10.94.200.1 with 32 bytes of data:
Reply from 10.94.200.153: Destination host unreachable.
Reply from 10.94.200.153: Destination host unreachable.
Reply from 10.94.200.153: Destination host unreachable.
Reply from 10.94.200.153: Destination host unreachable.
Ping statistics for 10.94.200.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
C:\tmp>ping 10.94.200.2
Pinging 10.94.200.2 with 32 bytes of data:
Request timed out.
Reply from 10.94.200.2: bytes=32 time=1ms TTL=255
Reply from 10.94.200.2: bytes=32 time=1ms TTL=255
Reply from 10.94.200.2: bytes=32 time=1ms TTL=255
Ping statistics for 10.94.200.2:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 1ms, Average = 1ms
C:\tmp>ping 10.94.200.3
Pinging 10.94.200.3 with 32 bytes of data:
Reply from 10.94.200.153: Destination host unreachable.
Reply from 10.94.200.153: Destination host unreachable.
Ping statistics for 10.94.200.3:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Control-C
^C
C:\tmp>
本文深入探讨了Ping命令的各种高级使用技巧,包括连续Ping、解析地址、自定义数据包大小、设置不要分片标志及Ping整个网络范围等操作,帮助读者全面掌握网络诊断工具的潜力。

1877

被折叠的 条评论
为什么被折叠?



