虚拟机ping无法访问目标主机怎么解决 ping无法访问目标主机怎么回事



文章插图
虚拟机ping无法访问目标主机怎么解决 ping无法访问目标主机怎么回事

文章插图
“ping” 命令用于排除和诊断网络连接问题 , 并检查主机是否可访问 , 它适用于所有操作系统 。
“ping”命令的工作原理
Ping 数据包工作原理图
Ping 命令从“主机 A”(源)向“主机 B”(目标)发送一个 32 字节的 ICMP(互联网控制消息协议)数据包 , 并等待“主机 B”向“主机 A”响应一个 32 字节的数据包” 。如果连接成功 , 则打印整个往返时间 , 如果不成功 , 则打印失败原因 , 诸如丢包、超时、连接错误等 。
如何执行“ping”命令?
以下是调用“ping”命令的方法:
ping [IP/domain] 例子:
ping gceasy.com 执行上述命令后 , 控制台会打印以下消息:
Pinging gceasy.com [195.201.17.137] with 32 bytes of data:Reply from 195.201.17.137: bytes=32 time=217ms TTL=45Reply from 195.201.17.137: bytes=32 time=185ms TTL=45Reply from 195.201.17.137: bytes=32 time=188ms TTL=45Reply from 195.201.17.137: bytes=32 time=196ms TTL=45Ping statistics for 195.201.17.137:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 185ms, Maximum = 217ms, Average = 196ms ?时间:这是往返时间 。它是数据包从源地址到达目的地并报告回源地址所花费的时间
?TTL(生存时间):是时间或“跳数”的量 , 它可以从 0 到 255 不等 , 具体取决于主机操作系统 。当数据包通过互联网发送时 , 数据包有可能从路由器通过 , 并且数据包将被发送 , 直到用户中断此命令 。数据包设计了一个称为生存时间的过期时间 。
?Ping statistics:
Packets Sent(发送的数据包): 数据包从主机发送到目的地的次数 。
Packets Received(收到的数据包) : 从目的地到主机收到的数据包的次数 。
Packets Lost(数据包丢失) : 无法到达目的地的数据包数 。
?大约往返时间:
最小值:以毫秒为单位获得响应的最短时间
平均:以毫秒为单位获得响应的平均时间
最大:以毫秒为单位获得响应的最长时间
Ping 的默认 TTL(生存时间) 是多少?
Ping 命令的 TTL值因操作系统而异 。下表总结了ping命令对于常用操作系统的默认TTL
Ping 错误:
?请求超时:如果由于网络流量过大 , 主机没有响应 , 或者 ARP 请求包过滤失败 , 或者如果路由器出现错误 , 则 ping 请求将超时 。
例子:
ping gceasy.ioPinging gceasy.io [52.52.12.54] with 32 bytes of data:Request timed out.Request timed out.Request timed out.Request timed out.Ping statistics for 52.52.12.54:Packets: Sent = 4, Received = 0, Lost = 4 (100% loss) 解决方案:使用 ping -w 开关增加等待时间 。
?Ping 请求无法找到主机:当无法根据传递给 ping 命令的主机名确定 IP 地址时 , 将遇到此错误 。
例子:
ping test123blah.comPing request could not find host test123blah.com. Please check the name and try again. 解决方案:验证传递给 ping 命令的主机名 。验证 DNS 服务器是否可用/可从主机访问 。
?目标主机无法访问:当访问的主机停机或在网络上不可用时 , 将返回“目标主机无法访问”错误 。
例子:
ping 192.168.0.0Pinging 192.168.0.0 with 32 bytes of data:Reply from 192.168.0.102: Destination host unreachable.Reply from 192.168.0.102: Destination host unreachable.Reply from 192.168.0.102: Destination host unreachable.Reply from 192.168.0.102: Destination host unreachable.Ping statistics for 192.168.0.0:Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) 解决方案:验证目标主机是否已启动并正在运行 。修改本地路由表或通知路由器管理员 。
?TTL 在传输过程中过期: 当将数据包路由到目的地时出现重循环时 , TTL 将过期 。这将导致“TTL在传输中过期”错误 。
解决方案: 确定重复并导致循环的 IP 地址 。在 Linux 问题上 , 以 root 用户身份使用“route -n”命令查看当前路由表 , 在 Windows 问题上 , 命令输出“route print” 。
?Ping命令:传输失败 。
一般故障:当设备网卡或无线适配器存在物理问题时 , 将导致“Ping:transmit failed. ”(Ping:传输失败)、“一般失败’错误 。
例子:
ping 2DAB:FFFF:0000:3EAE:01AA:00FF:DD72:2C4APinging 2dab:ffff:0:3eae:1aa:ff:dd72:2c4a with 32 bytes of data:PING: transmit failed. General failure.PING: transmit failed. General failure.PING: transmit failed. General failure.PING: transmit failed. General failure.Ping statistics for 2dab:ffff:0:3eae:1aa:ff:dd72:2c4a:Packets: Sent = 4, Received = 0, Lost = 4 (100% loss) 解决方案:确保网卡没有问题 。确保设备上安装了最新版本的网络驱动程序 , 检查是否为设备分配了正确的 IP 地址 。
常用的 Ping 命令
可以在使用 ‘ping’ 命令的同时使用其它选项来获取要查找的信息 。
发送更多请求 , 请执行以下操作:
如果要发送 ‘5’ 回显请求 , 则可以发出以下命令:
ping -n 5 gceasy.com 执行上述命令后 , 控制台会打印以下消息:
Pinging gceasy.com [195.201.17.137] with 32 bytes of data:Reply from 195.201.17.137: bytes=32 time=168ms TTL=45Reply from 195.201.17.137: bytes=32 time=165ms TTL=45Reply from 195.201.17.137: bytes=32 time=170ms TTL=45Reply from 195.201.17.137: bytes=32 time=170ms TTL=45Reply from 195.201.17.137: bytes=32 time=183ms TTL=45Ping statistics for 195.201.17.137:Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 165ms, Maximum = 183ms, Average = 171ms 要Ping指定主机直到停止 , 请执行以下操作:
如果想向指定的主机发送请求 , 直到手动停止为止 , 则可以发出以下命令:
ping -t gceasy.com Ping 工具
性能根本原因分析工具(如yCrash)捕获应用程序级工件(如线程转储、堆转储、垃圾收集日志)和系统级工件(如 netstat、vmstat、iostat、top、top -H、dmesg 等) 。除此之外 , 该工具还捕获 ping 命令输出 。工具分析所有工件 , 并立即生成统一的根本原因分析报告 。如果该工具在 ping 命令输出中发现任何错误 , 它将在报告中发出警报 。
图: yCrash工具中捕获并报告的 ping 输出
‘ping’ 命令选项
【虚拟机ping无法访问目标主机怎么解决 ping无法访问目标主机怎么回事】如果想了解传递给“ping”命令的所有选项 , 请参阅此处 。