首页 > 代码库 > ping命令总结

ping命令总结

1.1 功能说明

发送ICMP包到网络主机

1.2 语法格式

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

参数

说明

简解

-v

Verbose output.

详细输出

-i

interval

间隔的秒数

-c

count

数目,在发送指定数目的包后停止

-t

Set the IP Time to Live.

存活数值:设置存活数值TTL的大小

-s

packetsize

字节数:指定发送的数据字节数

1.3 实践操作

实例1-1  ping指定次数5

命令:ping –c 5 192.168.137.1

代码

[root@ben-test ~]# ping -c 5 192.168.137.1

PING 192.168.137.1 (192.168.137.1) 56(84) bytes ofdata.

64 bytes from 192.168.137.1: icmp_seq=1 ttl=64time=2.01 ms

64 bytes from 192.168.137.1: icmp_seq=2 ttl=64time=1.07 ms

64 bytes from 192.168.137.1: icmp_seq=3 ttl=64time=0.485 ms

64 bytes from 192.168.137.1: icmp_seq=4 ttl=64time=0.397 ms

64 bytes from 192.168.137.1: icmp_seq=5 ttl=64time=0.760 ms

 

--- 192.168.137.1 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss,time 4006ms

rtt min/avg/max/mdev = 0.397/0.944/2.012/0.584 ms

 

实例1-2  时间间隔0.5秒和次数5

命令:ping –i 0.5–c 5 192.168.137.1

代码

[root@ben-test ~]# ping -i 0.5 -c 5 192.168.137.1

PING 192.168.137.1 (192.168.137.1) 56(84) bytes ofdata.

64 bytes from 192.168.137.1: icmp_seq=1 ttl=64time=0.364 ms

64 bytes from 192.168.137.1: icmp_seq=2 ttl=64time=0.588 ms

64 bytes from 192.168.137.1: icmp_seq=3 ttl=64time=0.496 ms

64 bytes from 192.168.137.1: icmp_seq=4 ttl=64time=0.486 ms

64 bytes from 192.168.137.1: icmp_seq=5 ttl=64time=0.490 ms

 

--- 192.168.137.1 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss,time 2003ms

rtt min/avg/max/mdev = 0.364/0.484/0.588/0.076 ms

 

实例1-3   时间间隔0.5秒和次数5,包大小为1024

命令:ping –i 0.5–c 5 –s 1024 192.168.137.1

代码

[root@ben-test ~]# ping -i 0.5 -c 5 -s 1024192.168.137.1

PING 192.168.137.1 (192.168.137.1) 1024(1052) bytesof data.

1032 bytes from 192.168.137.1: icmp_seq=1 ttl=64time=0.561 ms

1032 bytes from 192.168.137.1: icmp_seq=2 ttl=64time=0.759 ms

1032 bytes from 192.168.137.1: icmp_seq=3 ttl=64time=0.447 ms

1032 bytes from 192.168.137.1: icmp_seq=4 ttl=64time=0.375 ms

1032 bytes from 192.168.137.1: icmp_seq=5 ttl=64time=0.525 ms

 

--- 192.168.137.1 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss,time 2003ms

rtt min/avg/max/mdev = 0.375/0.533/0.759/0.131 ms


本文出自 “斌少的技术博客” 博客,请务必保留此出处http://yinjianbin.blog.51cto.com/4529118/1874122

ping命令总结