解决ubuntu系统ping 不通 ip和默认网关的问题 您所在的位置:网站首页 电脑ping不了服务器是什么原因 解决ubuntu系统ping 不通 ip和默认网关的问题

解决ubuntu系统ping 不通 ip和默认网关的问题

2024-05-26 08:59| 来源: 网络整理| 查看: 265

1. 问题描述

OS: ubuntu 14.04 (1)ping 本地主机ip 192.168.1.105 OK (2)ping 默认网关 192.168.1.1 提示 From 192.168.1.125 destination host unreachable (3)ping 127.0.0.1 没问题(本地机回送地址) (4)ping同一个局域网段下的远程主机 192.168.1.101 同样提示 From 192.168.1.125 destination host unreachable

查询本机的ip信息,使用ifconfig 查询到如下: 在这里插入图片描述

2. 排查手段

2.1 首先检查了防火墙的问题,确认防火墙是关闭的:

sudo ufw status

返回的是 inactive , 说明防火墙是关闭的。如果要打开或者关闭防火墙,则使用如下指令:

sudo ufw enable sudo ufw disable

2.2 谷歌上搜索了相关问题,给出的回复如下,这里当时没明白到底是什么意思,但还是给后续解决这个问题提了个醒,因为ping ip/网关的时候命令行的返回里也有ip地址

Destination Host Unreachable This message indicates one of two problems: either the local system has no route to the desired destination, or a remote router reports that it has no route to the destination. The two problems can be distinguished by the form of the message. If the message is simply “Destination Host Unreachable,” then there is no route from the local system, and the packets to be sent were never put on the wire. Use the Route utility to check the local routing table. If the message is “Reply From < IP address >: Destination Host Unreachable,” then the routing problem occurred at a remote router, whose address is indicated by the “< IP address >” field. Use the appropriate utility or facility to check the IP routing table of the router assigned the IP address of < IP address >. If you pinged using an IP address, retry it with a host name to ensure that the IP address you tried is correct. 此消息指示两个问题之一:本地系统没有到所需目的地的路由,或者远程路由器报告它没有到目的地的路由。 这两个问题可以通过消息的形式来区分。 如果消息只是“目标主机不可达”,那么就没有来自本地系统的路由,并且要发送的数据包从未放在线路上。 使用路由实用程序检查本地路由表。 如果消息是“Reply From < IP address >:Destination Host Unreachable”,则路由问题发生在远程路由器上,其地址由“”字段指示。 使用适当的实用程序或工具检查分配了 < IP 地址 > 的 IP 地址的路由器的 IP 路由表。

2.3 既然ping网关都ping不通,于是就来查询一下本机的默认网关到底是多少,命令行输入ip route show 以后返回了两行,两行同样都是192.168.1.1 但是后面一个带有wlp2s0 一个后面带有enp1s0,当时没有拍照,大概的格式如下: default via 192.168.1.1 dev wlp2s0 default via 192.168.1.1 dev enp1s0

3. 最终解决

想起之前看到的网上另一种解决办法,传送门 大体思路是作者发现同一个网段有eth1和wlan1 ,大概的猜测是前者影响到后者了,于是我也按照这个思路去解决,在命令行输入 arp -a ,返回如下图 在这里插入图片描述 这里也是同一个网关下对应了两个以太网,wlp2s0和enp1s0,和之前查询默认网关一样,这里和前面查询ifconfig时也一一对应,因为也出现了两个ip,如下图:在这里插入图片描述 最后把出现在前面的那个enp1s0禁掉,输入指令

sudo ifconfig enp1s0 down

再次ping 网关和远程主机就ping得通了

在这里插入图片描述 2023年5月8日补充,如果大家是两个都要用,而两个都在同一个网段下的话,建议修改另一个网络接口的网段就好了,不需要输入指令sudo ifconfig enp1s0 down禁掉



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有