简体   繁体   English

Docker网络Macvlan驱动程序:网关无法访问

[英]Docker network macvlan driver: gateway unreachable

I have a macvlan network created with the following command: 我有一个使用以下命令创建的macvlan网络:

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

Where wlp2s0 is the name of the wireless interface of my laptop. 其中wlp2s0是我的笔记本电脑的无线接口的名称。 gateway is 192.168.1.1 and subnet 192.168.1.0/24 网关是192.168.1.1和子网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

In addition I have created a virtual machine using, virtualbox provider, with bridged network interface. 此外,我还使用带有桥接网络接口的virtualbox provider创建了一个虚拟机。

if I use ping command: - docker container -> vm ubuntu (ip of vm: 192.168.1.200) : ping works 如果我使用ping命令:-docker容器-> vm ubuntu(vm的IP:192.168.1.200):ping可以工作

but if I use ping command: - docker container -> gateway 192.168.1.1 or - docker container -> external world (google.com): ping not works 但是如果我使用ping命令:-docker容器->网关192.168.1.1或-docker容器->外部世界(google.com):ping不起作用

suggestions? 建议?

edit 1: 编辑1:

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

  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 

Where 192.168.1.56 is my docker container and 216.58.205.142 should be google ip address. 其中192.168.1.56是我的docker容器,而216.58.205.142应该是google ip地址。 No echo reply is received. 没有收到回音回复。

Macvlan is unlikely to work with IEEE 802.11. Macvlan不太可能与IEEE 802.11一起使用。

Your wifi access point, and/or your host network stack, are not going to be thrilled. 您的wifi接入点和/或主机网络堆栈不会令人兴奋。

You might want to try ipvlan instead: add -o ipvlan_mode=l2 to your network creation call and see if that helps. 您可能想尝试使用ipvlan:将-o ipvlan_mode=l2添加到您的网络创建调用中,看看是否有帮助。

That might very well still not work... (for eg, if you rely on DHCP and your DHCP server uses macaddresses and not client id) 可能仍然无法正常工作...(例如,如果您依赖DHCP,而您的DHCP服务器使用的是macaddresses而不是client id)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM