通过 ping 192.168.0.1 举例,也可以直接 ping baidu.com
# 直接 ping,无限次,1秒一次
$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=0.077 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.090 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.109 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.115 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.100 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.097 ms
......
# 指定 ping 6次就结束,1秒一次
$ ping -c6 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=0.077 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.090 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.109 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.115 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.100 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.097 ms
# 指定 ping 2次就结束,2秒一次
$ ping -c2 -i2 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=0.077 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.090 ms
# 指定 ping 超时时间
$ ping -W0.1 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
# 直接就不通了,因为时间太短