之前一直在用Ping,再仔细深入之后才发现自己只是了解皮毛。下面我把一些Ping的常用用法都记录下来,对于我来说今天又学了一个”神技”,哈哈哈。
#指定ping的次数 **-c**选项
[lhf@lv-centos ~]$ ping brianlv.com -c 3
PING brianlv.com (115.28.43.50) 56(84) bytes of data.
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=1 ttl=48 time=76.0 ms
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=2 ttl=48 time=77.4 ms
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=3 ttl=48 time=76.4 ms
--- brianlv.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 76.009/76.641/77.432/0.591 ms
如果想直接查看ping的结果而不去关注每次ping的延迟时间,可以通过如下命令:
#通过**-q**选项
[lhf@lv-centos ~]$ ping brianlv.com -c 3 -q
PING brianlv.com (115.28.43.50) 56(84) bytes of data.
--- brianlv.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2006ms
rtt min/avg/max/mdev = 77.516/77.744/77.915/0.363 ms
关注细节同学会发现,妹子ping之后都会有一个mdev的东东,全称是Mean Deviation。表示ICMP包的RTT偏离平均值的程度,用来衡量网络稳定性。mdev的值越大网络越不稳定。 指定ping的间隔时间,如下所示:
# 通过**-i**选项来设置。
[lhf@lv-centos ~]$ ping brianlv.com -c 3 -i 0.5
PING brianlv.com (115.28.43.50) 56(84) bytes of data.
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=1 ttl=49 time=77.8 ms
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=2 ttl=49 time=77.3 ms
64 bytes from 115.28.43.50 (115.28.43.50): icmp_seq=3 ttl=49 time=77.5 ms
--- brianlv.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1006ms
rtt min/avg/max/mdev = 77.335/77.596/77.859/0.386 ms
ping默认情况下使用1秒作为发送间隔,如果我们不想等待时间太长,想尽可能快速的发送数据包,可以使用如下命令:
#可以通过**-f**选项设置,即**flood ping**模式,它会尽全力采用无间隔的方式发送探测数据包,这种模式只有在root用户下才可以使用。
[root@lv-centos ~]# ping -f -c 100 brianlv.com
PING brianlv.com (115.28.43.50) 56(84) bytes of data.
--- brianlv.com ping statistics ---
100 packets transmitted, 100 received, 0% packet loss, time 1504ms
rtt min/avg/max/mdev = 77.078/78.073/81.789/0.907 ms, pipe 6, ipg/ewma 15.200/77.952 ms
ping不只是ping,继续探究中……