[lxc-users] How to release IP for inactive containers?

Fajar A. Nugraha list at fajar.net
Thu Apr 9 22:39:40 UTC 2015


On Fri, Apr 10, 2015 at 5:29 AM, Dan Shi <bruingo at gmail.com> wrote:
> I ran into a problem that only 253 containers get network connection. New
> containers after that can't getIP from lxc bridge, even if I stop/destroy
> existing running containers. The problem, apparently, is that the default in
> /etc/default/lxc-net, has LXC_DHCP_MAX set to 253.
>
> I suppose I can increase that number to have a large enough subnet. However,
> I'm wondering if there is a more elegant solution. For example, I can
> periodically call a script, or call it before destroying a container, to
> release IP for dead containers?

The elegant solution should be letting the container shutdown
gracefully (IIRC the default with lxc-stop since some time), which
should release its DHCP lease.

You could also look at /var/lib/misc/dnsmasq.lxcbr0.leases , but IMHO
it's not worth the effort. Simply adjust /etc/default/lxc-net
according to your needs (including changing its address and netmask if
you plan to use more than 253 max dhcp clients) and shutdown your
containers cleanly whenever possible.

See also dnsmasq man page
(http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html).

-- 
Fajar


More information about the lxc-users mailing list