menu Chancel's blog
rss_feed
Chancel's blog
有善始者实繁,能克终者盖寡。

Docker下WLAN网卡macvlan模式无法正常工作

作者:Chancel Yang, 创建:2023-04-03, 字数:1332, 已阅:48, 最后更新:2023-04-03

这篇文章更新于 421 天前,文中部分信息可能失效,请自行甄别无效内容。

Docker配置macvlan网络时,网上的例子一般都是针对有线网卡,当我尝试对无线网卡使用macvlan时发现失败了,失败过程如下

Bash
sudo docker network create -d macvlan --subnet=192.168.12.0/24 --gateway=192.168.12.1 -o parent=wlp0s20f3 super_magic_macvlan
sudo docker run --rm -it --network=super_magic_macvlan alpine /bin/sh
/ # ping 192.168.11.1
PING 192.168.11.1 (192.168.11.1): 56 data bytes
...
--- 192.168.12.1 ping statistics 3 packets transmitted, 0 packets received, 100% packet loss

连网关都无法正常访问,经查找,发现是macvlan模式不支持大部分无线网卡

access points don't like getting packets from MAC addresses that haven't previously authenticated with them.

改用ipvlan可以解决这个问题,验证如下

Bash
sudo docker network create -d ipvlan --subnet=192.168.1.0/24 -o ipvlan_mode=l2 parent=wlp0s20f3 super_magic_macvlan
sudo docker run --rm -it --network=wlp0s20f3_super_magic_network alpine /bin/sh
/ # ping 192.168.11.1
PING 192.168.11.1 (192.168.11.1): 56 data bytes
64 bytes from 192.168.11.1: seq=0 ttl=63 time=9.606 ms
64 bytes from 192.168.11.1: seq=1 ttl=63 time=5.379 ms
64 bytes from 192.168.11.1: seq=2 ttl=63 time=3.442 ms
64 bytes from 192.168.11.1: seq=3 ttl=63 time=4.412 ms
--- 192.168.11.1 ping statistics 24 packets transmitted, 4 packets received, 0% packet loss

参考资料

  • https://stackoverflow.com/questions/63037085/how-can-i-make-docker-container-ip-addresses-accessible-in-a-wlan

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
gravatar
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]