gns3-server
gns3-server copied to clipboard
docker VM started with "/usr/sbin/init" have the same MAC addresses
Hi
I have a template of docker VM, named "DDebian". His start command is "/usr/sbin/init", and has 6 network interfaces
On the lab, i put 3 VMs. The 6 mac addresses of a VM are the same of the other VM Example :
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
44: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether f6:b0:24:48:31:99 brd ff:ff:ff:ff:ff:ff
45: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether e2:71:dc:2e:b3:a9 brd ff:ff:ff:ff:ff:ff
46: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether c2:99:3a:f4:ec:bc brd ff:ff:ff:ff:ff:ff
47: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 96:21:c3:70:78:1a brd ff:ff:ff:ff:ff:ff
48: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 2e:7c:dd:7d:c6:48 brd ff:ff:ff:ff:ff:ff
49: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 22:45:ff:4c:3c:21 brd ff:ff:ff:ff:ff:ff
It is the same problem with 1 network interface.
I have not the bug if the start command is empty
Solved by add this empty file in the VM : /etc/systemd/network/99-default.link
This solution is not perfect : at each reboot, the MAC address are different (thus, a DHCP client will have a different IP on each reboot)
I've been getting to know systemd really well since I keep running into netplan doesn't )F#@)(@J#F support $x a lot.
So I had 2 boxes with virtual bridge interfaces come up that had the same MAC address. In theory as long as /etc/machine-id is unique then the MAC address get based on that. Of course I found that not to be true so I ended up changing the MACAddressPolicy for just bridge interfaces to be random.
https://www.freedesktop.org/software/systemd/man/systemd.link.html
I don't know what type of interface docker is creating. Bridge or dummy or what but if you figure that out you should be able to do the same. Once my lab is up i'll reply on how I did that for bridge interfaces.
Dear lord netplan is getting on my nerves.
$ more /etc/systemd/network/1-bridge-default.link
[Match]
kind=bridge
[Link]
MACAddressPolicy=random
Thanks @spikefishjohn
This 2 lines solve the problem :
echo -n > /etc/machine-id
echo -n > /var/lib/dbus/machine-id
( without to create the file /etc/systemd/network/99-default.link
)
Aah sorry I misunderstood your problem, but it looks like I gave you a hint that lead you where you needed to go.
but it looks like I gave you a hint that lead you where you needed to go.
Yes :-) thanks :-)
@Raizo62 is there anything we should implement on our side in regard to this issue?
Modify the 2 files works on Debian (perhaps with systemd), but i don't know if it works anywhere. I believe that docker can set the MAC addresses. GNS3 can perhaps do like with QEMU.
Correct, looks like we can set a base Mac Address when creating a Docker container: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerCreate
I tried to configure the Mac Address when creating the Docker container without any success. I believe this is because we manually create the interfaces in GNS3 (by creating a TAP and move it to the Docker's container namespace, all done by uBridge). So I think we would have to do it in uBridge directly however it is kinda complicated and we plan to move to Linux bridges for out network back-end at some point, not sure this is worth it...