ping命令
用法为:“ping 参数 目标主机”。其中参数为零到多个,目标主机可以是IP或者域名。
1、每隔0.6秒ping一次,一共ping 5次:
[root@aiezu.com ~]# ping -c 5 -i 0.6 qq.com
PING qq.com (14.17.32.211) 56(84) bytes of data.
64 bytes from 14.17.32.211: icmp_seq=1 ttl=54 time=16.5 ms
64 bytes from 14.17.32.211: icmp_seq=2 ttl=54 time=17.0 ms
64 bytes from 14.17.32.211: icmp_seq=3 ttl=54 time=16.6 ms
64 bytes from 14.17.32.211: icmp_seq=4 ttl=54 time=18.3 ms
64 bytes from 14.17.32.211: icmp_seq=5 ttl=54 time=19.9 ms
--- qq.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 2405ms
rtt min/avg/max/mdev = 16.520/17.692/19.919/1.293 ms
2、极限快速的使用大包ping:
以最快的速度,使用最大的包进行ping,可用于测试目标主机的承压能力:
[root@aiezu ~]# ping -f -s 65507 10.0.0.52
PING 10.0.0.52 (10.0.0.52) 65507(65535) bytes of data.
.^
--- 10.0.0.52 ping statistics ---
646 packets transmitted, 646 received, 0% packet loss, time 1675ms
rtt min/avg/max/mdev = 1.202/2.406/8.253/0.507 ms, ipg/ewma 2.598/2.318 ms
注意:此用法非常危险,65535(包头+内容)*100个包每秒=6.25MB,每秒发送6.25MB的数据,相当于50Mbps的带宽,完全可能导致目标主机拒绝服务。请勿用于非法用途,造成不良后果自负。
3、联通不稳定,丢包严重的情形:
下面的ping发出17个ping icmp包,而只有序号为8、9、12的包收到响应信息,丢包率达82%,联通非常不稳定:
[root@aiezu.com ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=8 ttl=43 time=32.3 ms
64 bytes from 8.8.8.8: icmp_seq=9 ttl=43 time=32.2 ms
64 bytes from 8.8.8.8: icmp_seq=12 ttl=43 time=32.0 ms
^C
--- 8.8.8.8 ping statistics ---
17 packets transmitted, 3 received, 82% packet loss, time 16003ms
rtt min/avg/max/mdev = 32.038/32.208/32.362/0.246 ms
4、完全无法ping通的情形:
[root@aiezu.com ~]# ping -c 3 9.9.9.9
PING 9.9.9.9 (9.9.9.9) 56(84) bytes of data.
--- 9.9.9.9 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms
参考文章:
ping命令:https://www.cnblogs.com/operationhome/p/9848138.html