0

I am using LXD with a standard configuration that assigns ipv4 private addresses to containers via DHCP/dnsmasq. When I reboot the host, some containers (not all) change ip address. I think those are containers that were created from the same container (via a copy or via a template that was published from another container). Those may rotate ip addresses between them. I checked that the virtual MAC addresses of the containers remain the same after host reboot and that each container has a different MAC adddress. Why then doesn't dnsmasq keep the same ip address and the same lease time? All the lease times change in /var/lib/lxd-bridge/dnsmasq.lxdbr0.leases after reboot. Why is this happening? Is it a bug?

How can I ensure that it doesn't happen? I can assign static ip addresses, but this would require an extra configuration step in several situations, e.g. each time the container is copied/moved to another server (which I sometimes do). It would also require an additional guest reboot to make sure that the configuration is correct.

1 Answer 1

1

I wouldn't touch the container config, as you said, you want to be able to move them.

How about you use dnsmasq to assign static IP-addresses over DHCP. You don't need to touch the container configs and always have the same addresses in every container.

Place that with the values you need in your dnsmasq.conf for every container

dhcp-host=MAC_ADDRESS,CONTAINER_NAME,IP_ADDRESS,LEASE_TIME

The MAC_ADDRESS or the CONTAINER_NAME is optional here. It only identifies the client and assigns the IP_ADDRESS to that client.

2
  • Yes. I am adding: Specify the dnsmasq.conf file in the LXD_CONFILE parameter in /etc/default/lxd-bridge.
    – user13097
    Aug 31, 2016 at 14:31
  • This works for LXD 2.x. I couldn't get it to work with LXD 3.x snap.
    – user13097
    Sep 13, 2018 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .