Docker网络Macvlan驱动程序:网关无法访问 [英] Docker network macvlan driver: gateway unreachable

查看:82
本文介绍了Docker网络Macvlan驱动程序:网关无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令创建了一个macvlan网络:

I have a macvlan network created with the following command:

docker network create -d macvlan --subnet=192.168.1.0/24  --gateway=192.168.1.2  -o parent=wlp2s0 pub_ne 

wlp2s0是笔记本电脑无线接口的名称.网关是192.168.1.1,子网是192.168.1.0/24

Where wlp2s0 is the name of the wireless interface of my laptop. gateway is 192.168.1.1 and subnet 192.168.1.0/24

然后我创建了一个容器并将其附加到该网络:

Then I have created and attached a container to this network:

docker run --rm -itd  --network pub_ne  --name myAlpine alpine:latest  sh

此外,我还使用带有桥接网络接口的virtualbox provider创建了一个虚拟机.

In addition I have created a virtual machine using, virtualbox provider, with bridged network interface.

如果我使用ping命令:-docker容器-> vm ubuntu(vm的IP:192.168.1.200):ping有效

if I use ping command: - docker container -> vm ubuntu (ip of vm: 192.168.1.200) : ping works

但是如果我使用ping命令:-docker容器->网关192.168.1.1或者-docker容器->外部世界(google.com):ping不起作用

but if I use ping command: - docker container -> gateway 192.168.1.1 or - docker container -> external world (google.com): ping not works

建议?

修改1:

在docker主机上,如果我运行tcpdump( tcpdump -i icmp ),我会看到:

On docker host if i run tcpdump ( tcpdump -i icmp ) i see:

    14:53:30.015822 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 29, length 64
14:53:31.016143 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 30, length 64
14:53:32.016426 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 31, length 64
14:53:33.016722 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 32, length 64

其中192.168.1.56是我的docker容器,而216.58.205.142应该是google ip地址.没有收到回音回复.

Where 192.168.1.56 is my docker container and 216.58.205.142 should be google ip address. No echo reply is received.

推荐答案

Macvlan不太可能与IEEE 802.11一起使用.

Macvlan is unlikely to work with IEEE 802.11.

您的wifi接入点和/或主机网络堆栈不会令人兴奋.

Your wifi access point, and/or your host network stack, are not going to be thrilled.

您可能想尝试使用ipvlan:将 -o ipvlan_mode = l2 添加到您的网络创建调用中,看看是否有帮助.

You might want to try ipvlan instead: add -o ipvlan_mode=l2 to your network creation call and see if that helps.

这可能仍然不起作用...(例如,如果您依赖DHCP,而您的DHCP服务器使用macaddress而不是客户端ID)

That might very well still not work... (for eg, if you rely on DHCP and your DHCP server uses macaddresses and not client id)

您唯一(合理的)解决方案可能是完全断开wifi并改为连接设备...(或远离macvlan并使用主机/网桥-以最方便的方式为准)

And your only (reasonable) solution might be to drop the wifi entirely and wire the device up instead... (or move away from macvlan and use host / bridge - whichever is the most convenient)

这篇关于Docker网络Macvlan驱动程序:网关无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆