linux常用命令:ping 命令
Linux系统的ping 命令是常用的网络命令,它通常用来测试与目标主机的连通性,我们经常会说“ping一下某机器,看是不是开着”、不能打开网页时会说“你先ping网关地 址192.168.1.1试试”。它通过发送ICMP ECHO_REQUEST数据包到网络主机 (send ICMP ECHO_REQUEST to network hosts),并显示响应情况,这样我们就可以根据它输出的信息来确定目标主机 是否可访问(但这不是绝对的)。有些服务器为了防止通过ping探测到,通过防火墙设置了禁止ping或者在内核参数中禁止ping,这样就不能通过 ping确定该主机是否还处于开启状态。
linux下的ping和windows下的ping稍有区别,linux下ping不会自动终止,需要按ctrl+c终止或者用参数-c指定要求完成的回应次数。
1.命令格式:
ping [参数] [主机名或IP地址]
2.命令功能:
ping命令用于:确定网络和各外部主机的状态;跟踪和隔离硬件和软件问题;测 试、评估和管理网络。如果主机正在运行并连在网上,它就对回送信号进行响应。每个回送信号请求包含一个网际协议(IP)和 ICMP 头,后面紧跟一 个 tim 结构,以及来填写这个信息包的足够的字节。缺省情况是连续发送回送信号请求直到接收到中断信号(Ctrl-C)。
ping 命 令每秒发送一个数据报并且为每个接收到的响应打印一行输出。ping 命令计算信号往返时间和(信息)包丢失情况的统计信息,并且在完成之后显示一个简要 总结。ping 命令在程序超时或当接收到 SIGINT 信号时结束。Host 参数或者是一个有效的主机名或者是因特网地址。
3.命令参数:
-b 运行ping一个广播地址
-c 指定次数
-d 使用Socket的SO_DEBUG功能。
-f 极限检测。大量且快速地送网络封包给一台机器,看它的回应。
-n 只输出数值。
-q 不显示任何传送封包的信息,只显示最后的结果。
-r 忽略普通的Routing Table,直接将数据包送到远端主机上。通常是查看本机的网络接口是否有问题。
-R 记录路由过程。
-v 详细显示指令的执行过程。
<p>-c 数目:在发送指定数目的包后停止。
-i 秒数:设定间隔几秒送一个网络封包给一台机器,预设值是一秒送一次。
-I 网络界面:使用指定的网络界面送出数据包。
-l 前置载入:设置在送出要求信息之前,先行发出的数据包。
-p 范本样式:设置填满数据包的范本样式。
-s 字节数:指定发送的数据字节数,预设值是56,加上8字节的ICMP头,一共是64ICMP数据字节。
-t 存活数值:设置存活数值TTL的大小。
4.使用实例:
实例1:ping的通的情况
命令:
ping 192.168.120.205
输出:
[root@localhost ~]# ping 192.168.120.205 PING 192.168.120.205 (192.168.120.205) 56(84) bytes of data. 64 bytes from 192.168.120.205: icmp_seq=1 ttl=64 time=0.720 ms 64 bytes from 192.168.120.205: icmp_seq=2 ttl=64 time=0.181 ms 64 bytes from 192.168.120.205: icmp_seq=3 ttl=64 time=0.191 ms 64 bytes from 192.168.120.205: icmp_seq=4 ttl=64 time=0.188 ms 64 bytes from 192.168.120.205: icmp_seq=5 ttl=64 time=0.189 ms --- 192.168.120.205 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4000ms rtt min/avg/max/mdev = 0.181/0.293/0.720/0.214 ms [root@localhost ~]#
说明:
实例2:ping不通的情况
命令:
ping 192.168.120.202
输出:
[root@localhost ~]# ping 192.168.120.202 PING 192.168.120.202 (192.168.120.202) 56(84) bytes of data. From 192.168.120.204 icmp_seq=1 Destination Host Unreachable From 192.168.120.204 icmp_seq=2 Destination Host Unreachable From 192.168.120.204 icmp_seq=3 Destination Host Unreachable From 192.168.120.204 icmp_seq=4 Destination Host Unreachable From 192.168.120.204 icmp_seq=5 Destination Host Unreachable From 192.168.120.204 icmp_seq=6 Destination Host Unreachable --- 192.168.120.202 ping statistics --- 8 packets transmitted, 0 received, +6 errors, 100% packet loss, time 7005ms , pipe 4 [root@localhost ~]#
说明:
实例3:ping网关
命令:
ping -b 192.168.120.1
输出:
[root@localhost ~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.120.0 * 255.255.255.0 U 0 0 0 eth0 192.168.0.0 192.168.120.1 255.255.0.0 UG 0 0 0 eth0 10.0.0.0 192.168.120.1 255.0.0.0 UG 0 0 0 eth0 default 192.168.120.240 0.0.0.0 UG 0 0 0 eth0 [root@localhost ~]# ping -b 192.168.120.1 PING 192.168.120.1 (192.168.120.1) 56(84) bytes of data. 64 bytes from 192.168.120.1: icmp_seq=1 ttl=255 time=2.02 ms 64 bytes from 192.168.120.1: icmp_seq=2 ttl=255 time=1.83 ms 64 bytes from 192.168.120.1: icmp_seq=3 ttl=255 time=1.68 ms 64 bytes from 192.168.120.1: icmp_seq=4 ttl=255 time=1.98 ms 64 bytes from 192.168.120.1: icmp_seq=5 ttl=255 time=1.88 ms --- 192.168.120.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4000ms rtt min/avg/max/mdev = 1.682/1.880/2.020/0.129 ms
说明:
实例4:ping指定次数
命令:
ping -c 10 192.168.120.206
输出:
[root@localhost ~]# ping -c 10 192.168.120.206 PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data. 64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.25 ms 64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.260 ms 64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.242 ms 64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.271 ms 64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.274 ms 64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.295 ms 64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.269 ms 64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.270 ms 64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.253 ms 64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.289 ms --- 192.168.120.206 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 9000ms rtt min/avg/max/mdev = 0.242/0.367/1.251/0.295 ms [root@localhost ~]#
说明:
实例5:时间间隔和次数限制的ping
命令:
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. 64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.24 ms 64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.235 ms 64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.244 ms 64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.300 ms 64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.255 ms 64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.264 ms 64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.263 ms 64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.331 ms 64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.247 ms 64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.244 ms --- 192.168.120.206 ping statistics --- 10 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. 64 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=0.244 ms 64 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.195 ms 64 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.219 ms 64 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.204 ms 64 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=3.56 ms 64 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=1.93 ms 64 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.193 ms 64 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.193 ms 64 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.202 ms 64 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.211 ms --- 192.168.120.206 ping statistics --- 10 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 ~]#
说明:
实例6:通过域名ping公网上的站点
命令:
ping -c 5 www.58.com
输出:
peida-VirtualBox ~ # ping -c 5 www.58.com PING www.58.com (211.151.111.30) 56(84) bytes of data. 64 bytes from 211.151.111.30: icmp_req=1 ttl=49 time=14.7 ms 64 bytes from 211.151.111.30: icmp_req=2 ttl=49 time=16.4 ms 64 bytes from 211.151.111.30: icmp_req=3 ttl=49 time=15.2 ms 64 bytes from 211.151.111.30: icmp_req=4 ttl=49 time=14.6 ms 64 bytes from 211.151.111.30: icmp_req=5 ttl=49 time=19.9 ms --- www.58.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 20101ms rtt min/avg/max/mdev = 14.618/16.192/19.917/1.965 ms peida-VirtualBox ~ #
说明:
实例7:多参数使用
命令:
ping -i 3 -s 1024 -t 255 192.168.120.206
输出:
[root@localhost ~]# ping -i 3 -s 1024 -t 255 192.168.120.206 PING 192.168.120.206 (192.168.120.206) 1024(1052) bytes of data. 1032 bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.99 ms 1032 bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.694 ms 1032 bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.300 ms 1032 bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.481 ms 1032 bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.415 ms 1032 bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.600 ms 1032 bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.411 ms 1032 bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.281 ms 1032 bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.318 ms 1032 bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.362 ms 1032 bytes from 192.168.120.206: icmp_seq=11 ttl=64 time=0.408 ms 1032 bytes from 192.168.120.206: icmp_seq=12 ttl=64 time=0.445 ms 1032 bytes from 192.168.120.206: icmp_seq=13 ttl=64 time=0.397 ms 1032 bytes from 192.168.120.206: icmp_seq=14 ttl=64 time=0.406 ms 1032 bytes from 192.168.120.206: icmp_seq=15 ttl=64 time=0.458 ms --- 192.168.120.206 ping statistics --- 15 packets transmitted, 15 received, 0% packet loss, time 41999ms rtt min/avg/max/mdev = 0.281/0.531/1.993/0.404 ms [root@localhost ~]#
说明:
-i 3 发送周期为 3秒 -s 设置发送包的大小为1024 -t 设置TTL值为 255
linux常用命令:ping 命令的更多相关文章
- ## 本篇文章对linux常用的一些命令做一下总结,如有需要补充以及不懂得地方,请在下方留言 适合于linux初学者,以及对命令掌握不牢的用来备忘
本篇文章对linux常用的一些命令做一下总结,如有需要补充以及不懂得地方,请在下方留言 适合于linux初学者,以及对命令掌握不牢的用来备忘一,磁盘管理1.显示当前目录位置 pwd2.切换目录 cd ...
- Linux 常用的压缩命令有 gzip 和 zip
Linux 常用的压缩命令有 gzip 和 zip,两种压缩包的结尾不同:zip 压缩的后文件是 *.zip ,而 gzip 压缩后的文件 *.gz 相应的解压缩命令则是 gunzip 和 unzip ...
- linux常用60条命令 转
Linux必学的60个命令 Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命 ...
- 入门学习Linux常用必会命令实例详解
Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令.要想真正理解Linux系统, ...
- 网络编程学习笔记-linux常用的网络命令
网络参数设置命令 所有时刻如果你想要做好自己的网络参数设置,包括IP参数.路由参数和无线网络等,就得要了解下面这些相关的命令才行.其中Route及ip这两条命令是比较重要的.当然,比较早期的用法,我们 ...
- linux常用配置文件和命令总结
常用配置文件说明: 1..设置-n永远生效:Vim的配置文件:命令模式想永久生效, ~/.vimrc,新建文件,在里面输入保存即可 2.设置别名永远生效:在~/.bashrc 修改当前用户家目录里的 ...
- windows 环境和linux环境下 ping命令的区别:
Ping 是Windows自带的一个DOS命令.利用它可以检查网络是否能够连通,用好它可以很好地帮助我们分析判定网络故障.该命令可以加许多参数使用,键入Ping按回车即可看到详细说明.Ping 命令可 ...
- LINUX常用配置及命令
一. Fedora系统配置 1. [设置网卡IP] 步骤如下: 1) 用root用户登陆,打开/etc/sysconfig/network-scripts/ifcfg-eth0文 ...
- Linux常用的网络命令
这些命令都是我在浏览网页的时候偶然看到的,但是不太完整,所以我就整理了一下,详见如下. 1.查看网络接口状态 ifconfig(interface configuration,接口配置),通常会加上- ...
- Linux常用的基础命令总结
man 查看英文命令帮助 可以看作--help 拷贝目录的命令cp -a 包含所有 ls -a 显示所有文件包括隐藏文件 -ld ls -F 过滤目录文件(给不同类型文件结尾加上不同的符号) ...
随机推荐
- [MySQL]修改root密码的4种方法(以windows为例)
方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...
- Android ScrollView嵌套ScrollView滚动的问题解决办法
引用:http://mengsina.iteye.com/blog/1707464 http://fenglog.com/article.asp?id=449 Android ScrollView嵌套 ...
- 基于Token的多平台身份认证价格设计
1 概述 在存在账号体系的信息系统中,对身份的鉴定是非常重要的事情. 随着移动互联网时代到来,客户端的类型越来越多, 逐渐出现了 一个服务器,N个客户端的格局 . 不同的客户端产生了不同的用户使用 ...
- Memcached 简单利用和简单了解(Mac的安装和使用)
Memcached 是一种用于分布式应用的一种缓存机制.应用也比较广泛.这里来学习一下. 首先Memcached 是分布式网站架构都需要用到的缓存机制.缓存就是服务器利用多余的空间上开辟了一个储存空间 ...
- php iconv() : Detected an illegal character in input string
php iconv() : Detected an illegal character in input string_php技巧_脚本之家 https://www.jb51.net/article/ ...
- ONLYstore_name+AdWord
情景描述ONLYstore_name+AdWord 基础表数据表 BASE_TABLEAdWord food drink1w1 1f1 1d12w2 2f_ 2d_3w1 ...
- Python 目录【持续更新中】
Python 基础 字符编码 数据类型 文件处理 流程控制 练习题 函数,递归 匿名函数.内置函数 装饰器变形记 函数装饰器 递归 二分法 迭代器和生成器 协程函数 列表表达式 生成器表达式 异常处理 ...
- Number Sequence--POJ1019
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35251 Accepted: 10151 ...
- dbms_stats.gather_table_stats详解
dbms_stats.gather_table_stats 统计表,列,索引的统计信息(包含该表的自身-表的行数.数据块数.行长等信息: 列的分析--列值的重复数.列上的空值.数据在列上的分布情 ...
- jquery实现选项卡(两句即可实现)
<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> ...