1.概述

ping常用于检测网络状况。

2.各参数含义

-c count,当ping到一定数量后终止ping。

-i interval ,ping包间隔

-I interface address,网卡,IP所在网卡ping出

-s packetsize,包大小,包含8字节icmp头

-S 指定源地址

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
[root@smart Desktop]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.576 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.790 ms
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1541ms
rtt min/avg/max/mdev = 0.576/0.683/0.790/0.107 ms
[root@smart Desktop]# ping 192.168.1.1 -c 2
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.550 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.600 ms

--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.550/0.575/0.600/0.025 ms
[root@smart Desktop]# ping 192.168.1.1 -i 192.168.1.120
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.709 ms

^C
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 12166ms
rtt min/avg/max/mdev = 0.709/0.709/0.709/0.000 ms
[root@smart Desktop]# ping 192.168.1.1 -I 192.168.1.20
bind: Cannot assign requested address
[root@smart Desktop]# ping 192.168.1.1 -I 192.168.1.120
PING 192.168.1.1 (192.168.1.1) from 192.168.1.120 : 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.784 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.681 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.509 ms
^C
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2182ms
rtt min/avg/max/mdev = 0.509/0.658/0.784/0.113 ms
[root@smart Desktop]# ping 192.168.1.1 -s 1000
PING 192.168.1.1 (192.168.1.1) 1000(1028) bytes of data.
1008 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.987 ms
1008 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.964 ms
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1885ms
rtt min/avg/max/mdev = 0.964/0.975/0.987/0.033 ms