admin 管理员组文章数量: 887021
情况描述,物理机win10(192.168.1.102),虚拟机Ubuntu 18(192.168.190.128) docker环境 nat设置
物理机可以ping通虚拟机,虚拟机可以访问外网,但是不能ping通物理主机,虚拟机ping 192.68.1.102如下图
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=1 Destination Host Unreachable
From 192.168.0.1 icmp_seq=2 Destination Host Unreachable
From 192.168.0.1 icmp_seq=3 Destination Host Unreachable
一开始,从网上找各种解决方法,修改interface、修改nameserver等,都没用用。
仔细分析,上面的出错结果,很奇怪的是ping 192.168.1.1 怎么从192.168.0.1返回数据,猜测可能是路由出现问题,查看路由表发现192.168.190.0/24数据没有走网关,此处可以判断路问题。
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 ens33
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-3d2e6a9d7f7a
172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-2bab04dfa3a9
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-e121c20fd9c5
172.21.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-93d1ae7f81de
172.22.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-fc860270f1b0
172.23.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker_gwbridge
172.24.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-35791f8cd814
172.25.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-8c4222827c87
172.26.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-55ae606a5e37
172.27.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-3e05adbd8e63
172.28.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-7f297b5f5e96
172.29.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-21f604100080
172.30.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-10b4e0e91faf
172.31.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-54d9ba0e058e
192.168.0.0 0.0.0.0 255.255.240.0 U 0 0 0 br-38baa1899bf6
192.168.16.0 0.0.0.0 255.255.240.0 U 0 0 0 br-4c4803a7130c
192.168.32.0 0.0.0.0 255.255.240.0 U 0 0 0 br-7c8d0fddee99
192.168.190.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
_gateway 0.0.0.0 255.255.255.255 UH 100 0 0 ens33
添加路由,让192.168.1.0/24从网关192.168.190.2进出
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.190.2
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 ens33
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-3d2e6a9d7f7a
172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-2bab04dfa3a9
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-e121c20fd9c5
172.21.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-93d1ae7f81de
172.22.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-fc860270f1b0
172.23.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker_gwbridge
172.24.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-35791f8cd814
172.25.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-8c4222827c87
172.26.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-55ae606a5e37
172.27.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-3e05adbd8e63
172.28.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-7f297b5f5e96
172.29.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-21f604100080
172.30.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-10b4e0e91faf
172.31.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-54d9ba0e058e
192.168.0.0 0.0.0.0 255.255.240.0 U 0 0 0 br-38baa1899bf6
192.168.1.0 _gateway 255.255.255.0 UG 0 0 0 ens33
192.168.16.0 0.0.0.0 255.255.240.0 U 0 0 0 br-4c4803a7130c
192.168.32.0 0.0.0.0 255.255.240.0 U 0 0 0 br-7c8d0fddee99
192.168.190.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
_gateway 0.0.0.0 255.255.255.255 UH 100 0 0 ens33
再次ping 物理主机,ping通
添加路由
route add -net 10.10.10.0 netmask 255.255.255.0 gw 192.168.1.1
删除一条路由
route del -net 192.168.122.0 netmask 255.255.255.0
删除的时候不写网关
添加默认网关
route add default gw 192.168.1.4
本文标签: host Destination Ubuntu unreachable
版权声明:本文标题:Destination Host Unreachable Ubuntu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1726377950h948319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论