Windows ping 不通虚拟机里面的docker

发布于 2022-09-12 13:15:07 字数 3864 浏览 50 评论 0

|----------------------------------------|
|                                        |
|   |--------------------------------|   |
|   |                                |   |
|   |    docker(CentOS) 172.18.0.2   |   |
|   |--------------------------------|   |
|                                        |
| Virtual Machine(CentOS) 192.168.27.143 |
|----------------------------------------|

         Windows 192.168.137.123

Windows 可以 ping 虚拟机

虚拟机 可以 ping Windows

虚拟机 可以 ping docker

Docker 可以 ping 虚拟机

Docker 可以 ping Windows

但是 WINDOWS 不可以 PING DOCKER(request time out)

在虚拟机ifconfig

[root@docker ~]# ifconfig
br-fff1cd703408: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        inet6 fe80::42:7bff:fe3f:7669  prefixlen 64  scopeid 0x20<link>
        ether 02:42:7b:3f:76:69  txqueuelen 0  (Ethernet)
        RX packets 5  bytes 378 (378.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1480 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:b6:b4:25:97  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.27.143  netmask 255.255.255.0  broadcast 192.168.27.255
        inet6 fe80::5634:e3d1:16db:c070  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ee:e9:81  txqueuelen 1000  (Ethernet)
        RX packets 434  bytes 41635 (40.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 289  bytes 32577 (31.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 3  bytes 312 (312.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 312 (312.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethdd8e4ad: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::e467:dcff:fe56:3d24  prefixlen 64  scopeid 0x20<link>
        ether e6:67:dc:56:3d:24  txqueuelen 0  (Ethernet)
        RX packets 5  bytes 378 (378.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1480 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

在docker ifconfig

[root@master /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.2  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:ac:12:00:02  txqueuelen 0  (Ethernet)
        RX packets 31  bytes 2530 (2.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1428 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker commit -m "hadoop" -a "hxp" def8faf07d6b hxp/hadoop:1.0

docker network create --driver=bridge --subnet=172.18.0.0/16 hadoop-net

docker run -itd -h master --name master --network hadoop-net --privileged -v /opt/docker:/opt/docker --ip 172.18.0.2 -p 50070:50070 -p 8088:8088 hxp/hadoop:1.0 /usr/sbin/init

我尝试了在Windows route add ,但是还是不行

route add 172.18.0.0 mask 255.255.0.0 192.168.27.143

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美煞众生 2022-09-19 13:15:07

ping使用ICMP协议需要双向通信,你还需要在docker里面添加访问windows网络的路由。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文