一、作用

  1. 用于检测主机,会使用 ICMP 传输协议,发出要求回应的信息,若远端主机的网络功能没有问题,就会回应该信息,因而得知该主机运作正常

二、选项

  • -c <完成次数> 设置完成要求回应的次数
  • -i<间隔秒数> 指定收发信息的间隔时间
  • -W <设置超时时间>

    三、实例

    ```shell [root@localhost exerecise]# ping -c 4 114.114.114.114 PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data. 64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=30.2 ms 64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=30.5 ms 64 bytes from 114.114.114.114: icmp_seq=3 ttl=128 time=32.1 ms 64 bytes from 114.114.114.114: icmp_seq=4 ttl=128 time=29.0 ms

—- 114.114.114.114 ping statistics —- 4 packets transmitted, 4 received, 0% packet loss, time 3030ms rtt min/avg/max/mdev = 29.066/30.498/32.152/1.101 ms

```shell
[root@localhost exerecise]# ping -i 2 114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=25.8 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=24.3 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=128 time=22.9 ms
64 bytes from 114.114.114.114: icmp_seq=4 ttl=128 time=23.0 ms
64 bytes from 114.114.114.114: icmp_seq=5 ttl=128 time=21.9 ms
[root@localhost ~]# ping -c 4 -W 0.1 -i 0.1  114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=29.2 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=29.3 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=128 time=30.6 ms
64 bytes from 114.114.114.114: icmp_seq=4 ttl=128 time=32.8 ms

--- 114.114.114.114 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 305ms
rtt min/avg/max/mdev = 29.210/30.501/32.841/1.456 ms