【网络成长记】ping常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ping -h
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
[-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
[-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
[-l preload] [-m mark] [-M pmtudisc_option]
[-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize]
[-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline]
[-W timeout] destination



# 01. 每隔0.6秒ping一次,一共ping 5次
# ping -c 5 -i 0.6 qq.com
PING qq.com (58.247.214.47) 56(84) bytes of data.
64 bytes from 58.247.214.47 (58.247.214.47): icmp_seq=1 ttl=49 time=25.9 ms
64 bytes from 58.247.214.47 (58.247.214.47): icmp_seq=2 ttl=49 time=25.2 ms
64 bytes from 58.247.214.47 (58.247.214.47): icmp_seq=3 ttl=49 time=25.2 ms
64 bytes from 58.247.214.47 (58.247.214.47): icmp_seq=4 ttl=49 time=25.3 ms
64 bytes from 58.247.214.47 (58.247.214.47): icmp_seq=5 ttl=49 time=25.3 ms

--- qq.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 2404ms
rtt min/avg/max/mdev = 25.266/25.432/25.964/0.302 ms


## 02. 测试-I
# ping -I 172.28.157.146 qq.com
PING qq.com (58.250.137.36) from 172.28.157.146 : 56(84) bytes of data.
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=1 ttl=47 time=42.6 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=2 ttl=47 time=42.3 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=3 ttl=47 time=42.2 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=4 ttl=47 time=42.1 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=5 ttl=47 time=42.1 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=6 ttl=47 time=43.2 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=7 ttl=47 time=42.1 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=8 ttl=47 time=42.1 ms
64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=9 ttl=47 time=51.2 ms
^C
--- qq.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8008ms
rtt min/avg/max/mdev = 42.162/43.368/51.248/2.805 ms


# ping -I 192.168.20.201 qq.com
PING qq.com (58.247.214.47) from 192.168.20.201 : 56(84) bytes of data.
^C
--- qq.com ping statistics ---
6 packets transmitted, 0 received, 100% packet loss, time 5108ms


mdev 就是 Mean Deviation 的缩写,它表示这些 ICMP 包的 RTT 偏离平均值的程度,这个值越大说明你的网速越不稳定。

ping -t

1
2
3
4
5
6
7
8
9
10
11
# ping -t www.baidu.com
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
[-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
[-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
[-l preload] [-m mark] [-M pmtudisc_option]
[-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize]
[-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline]
[-W timeout] destination

ping -n

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# ping -n 2 192.168.3.100
PING 192.168.3.100 (192.168.3.100) 56(124) bytes of data.
^C
--- 192.168.3.100 ping statistics ---
9 packets transmitted, 0 received, 100% packet loss, time 8179ms



# ping 192.168.3.100 -n 2
PING 2 (0.0.0.2) 56(124) bytes of data.
^C
--- 2 ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 6139ms

[root@ningan dubhe-manager]#

ping -c

1
2
3
4
5
6
7
8
9
10
11
# ping 192.168.3.100 -c 5
PING 192.168.3.100 (192.168.3.100) 56(84) bytes of data.
64 bytes from 192.168.3.100: icmp_seq=1 ttl=52 time=26.0 ms
64 bytes from 192.168.3.100: icmp_seq=2 ttl=52 time=26.5 ms
64 bytes from 192.168.3.100: icmp_seq=3 ttl=52 time=25.7 ms
64 bytes from 192.168.3.100: icmp_seq=4 ttl=52 time=26.9 ms
64 bytes from 192.168.3.100: icmp_seq=5 ttl=52 time=26.6 ms

--- 192.168.3.100 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 25.753/26.369/26.920/0.443 ms

【网络成长记】ping常用命令
http://example.com/2023/05/11/net/【网络成长记】ping常用命令/
作者
ningan123
发布于
2023年5月11日
许可协议