gpt4 book ai didi

docker - 无法更改docker容器的mac地址

转载 作者:行者123 更新时间:2023-12-02 20:52:12 26 4
gpt4 key购买 nike

我尝试了以下

docker run -e lxc --lxc-conf="lxc.network.hwaddr=00:0C:29:88:30:CC" -i -t centos ifconfig

但是,正如您从我的outuput中看到的那样,它不会更改mac地址
eth0: flags=3<UP,BROADCAST>  mtu 1500
inet 172.17.0.6 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:acff:fe11:6 prefixlen 64 scopeid 0x20<link>
ether 02:42:ac:11:00:06 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 90 (90.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 90 (90.0 B)
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 0 (Local Loopback)
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

我在Ubuntu上运行docker 1.3,并从centos7镜像生成了容器
Client version: 1.3.2
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 39fa2fa
OS/Arch (client): linux/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa

我将很高兴为您成功更改容器中的Mac地址提供任何帮助。

最佳答案

如果查看https://github.com/docker/docker/blob/v1.4.1/vendor/src/github.com/docker/libcontainer/netlink/netlink_linux.go#L528上的docker代码,则会看到仅接受非广播的本地mac地址。在https://en.wikipedia.org/wiki/MAC_address中搜索“组织唯一标识符”以获取说明。实际上,这意味着MAC的第二个字符必须为2、6,A或E。

如果运行docker run --mac-address=00:0C:29:88:30:CC centos ifconfig,您应该会看到一条错误消息,该错误消息来自上述代码。

关于docker - 无法更改docker容器的mac地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27417981/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com