Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lxd (ubuntu 16.10) container mac address

I am running the latest Ubuntu (16.10) with LXD containers. Containers are configured with bridged networking, and they receive their own IP addresses from the DHCP server. I have configured them with the following:

lxc profile device add default eth0 nic nictype=bridged parent=br0

lxc network attach br0

Now, I need to set hardware addresses (MAC) manually for each of the containers, so their corresponding static IPs never change. However, I am having a hard time of doing so with lxc. Do I just set them in the corresponding /etc/network/interfaces, or is there a better (lxd/lxc) way of doing it?

like image 228
bytebybyte Avatar asked Sep 15 '25 23:09

bytebybyte


1 Answers

Each container will keep the same MAC address as it was at first launch time. To get its value:

lxc config show container_name
  or, more precise
lxc config get container_name volatile.NIC_NAME.hwaddr

This is not like in case of pure lxc when you had to manually set it in /var/lib/lxc/container_name/config.

But, if you really need to use your own set of MAC addresses(assuming eth0 is nic for container):

lxc config set container_name volatile.eth0.hwaddr yo:ur:ma:ca:dd:ress
like image 118
Theodor Avatar answered Sep 17 '25 17:09

Theodor