New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container getting different IP Address on LXD host reboot. #6667
Comments
Most Linux systems issue a DHCP RELEASE on shutdown marking their lease as unused and available for reuse. It's then up to the individual DHCP server to decide what to do. Most will try to give back the same address based on past leases but there is no guarantee. dnsmasq is using some kind of hash on the MAC to find a suitable lease, given that container MACs are very similar (same first 24 bits) and the IP space is limited (8 bits), the hash mechanism will often collide and so cause containers to switch addresses when no active lease is present AND the address is unused. The normal expiry time may also be at play (1h). If that's the case, bumping it to a higher value on the bridge will help. If you don't want addresses to potentially change, it's best to set a static lease on the nic device (ipv4.address). |
Yes, I had resorted to using static IP's; had to learn Does |
@ak2766 you shouldn't need to use netplan to configure static assignments, as LXD supports specifying static IP assignments via dnsmasq's DHCP. e.g.
This will instruct dnsmasq to always give out the static IP to the container's MAC address. This way dnsmasq is aware of the static assignments and will not allocate them to dynamic containers. If you do want to use netplan to statically assign instead, then LXD disable's the dnsmasq feature that performs a ping to check whether an address is active before allocating it as this slows down container boot. There is also a scenario one could consider where a manually configured container is stopped, and a dynamic container boots up and is assigned the IP of the manually configured container. So even with the ping option in dnsmasq, it is not guaranteed safe, and in that situation it would be best to split the dynamic address range (which can be configured by LXD's network options https://linuxcontainers.org/lxd/docs/master/networks#bridges). |
@tomponline Thank you so much for going into detail. I've used |
This didn't work for me. My container still has the old IP:
Worth mentioning, is that another container (stopped) was assigned the same IP which might be present in the dnsmasq? If that is the case, how would I deal with this situation as I would expect the static assignment to have some precedence over dynamic leases ... right? [update] lxc list This makes absolutely no sense at all to me.
[update] A) Find whatever container seems to be holding the ip-address I want and... [update] This situation is either right, or wrong, since it would require me to actually START the conflicting container, before I can resolve the situation. While I now know how to sort of get out of my current issue, it still leaves the three questions: A) Find whatever container seems to be holding the ip-address I want and... |
Required information
Issue description
Whenever the LXD host is rebooted, some containers intermittently come up with different IP addresses yet MAC addresses have not changed. Is this a known issue?
I would have thought that DHCP leases would be stored on the host file system and that this file would be referenced when a container requests for an IP on reboot.
Steps to reproduce
Information to attach
N/A
The text was updated successfully, but these errors were encountered: