Linux下ping命令可以设置每次ping的时间间隔。下面由学习啦小编为大家整理了linux下ping命令设置时间间隔的相关知识,希望对大家有帮助!

linux的ping命令设置时间间隔详解

ping命令用来测试主机之间网络的连通性。

(1)用法:

用法: ping [参数] [主机名或IP地址]

(2)功能:

功能: 确定网络和各外部主机的状态;跟踪和隔离硬件和软件问题;测试、评估和管理网络。

细节: 执行ping指令会使用ICMP传输协议,发出要求回应的信息,若远端主机的网络功能没有问题,就会回应该信息,因而得知该主机运作正常。例如: “ping一下某机器,看是不是开着”、不能打开网页时“先ping网关地址192.168.1.1试试”。ping 命令每秒发送一个数据报并且为每个接收到的响应打印一行输出。ping 命令计算信号往返时间和(信息)包丢失情况的统计信息,并且在完成之后显示一个简要总结。ping 命令在程序超时或当接收到 SIGINT 信号时结束。Host 参数或者是一个有效的主机名或者是因特网地址。

注意: 有些服务器为了防止通过ping探测到,通过防火墙设置了禁止ping或者在内核参数中禁止ping,这样就不能通过ping确定该主机是否还处于开启状态。

(3)选项参数:

1) -b n:        测试与网关IP的连通性

2) -c n:       执行指定次数 n的ping命令

3) -i n:       设定间隔几秒送一个网络封包给一台机器,预设值是一秒送一次。

4) -s 字节数:     指定发送的数据字节数,预设值是56,加上8字节的ICMP头,一共是64ICMP数据字节。

5) -t 存活数值:    设置存活数值TTL的大小。

linux的ping命令设置时间间隔和参数限制实例

1)[root@localhost ~]# ping -c 10 -i 0.5 192.168.120.206

[root@localhost ~]# ping -c 10 -i 0.5 192.168.120.206

PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.

bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.24 ms

bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.235 ms

bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.244 ms

bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.300 ms

bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.255 ms

bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.264 ms

bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.263 ms

bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.331 ms

bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.247 ms

bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.244 ms

--- 192.168.120.206 ping statistics ---

packets transmitted, 10 received, 0% packet loss, time 4499ms

rtt min/avg/max/mdev = 0.235/0.362/1.241/0.294 ms

[root@localhost ~]# ping -c 10 -i 0.01 192.168.120.206

PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.

bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=0.244 ms

bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.195 ms

bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.219 ms

bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.204 ms

bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=3.56 ms

bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=1.93 ms

bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.193 ms

bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.193 ms

bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.202 ms

bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.211 ms

--- 192.168.120.206 ping statistics ---

packets transmitted, 10 received, 0% packet loss, time 90ms

rtt min/avg/max/mdev = 0.193/0.716/3.564/1.080 ms

[root@localhost ~]#

Logo

更多推荐