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

Dan Shi bruingo at gmail.com
Sat Apr 11 00:47:12 UTC 2015


One dumb question, how can I setup lxc-net to support a subnet larger than
253? I tried following:
LXC_NETWORK="10.0.3.0/16"
LXC_DHCP_RANGE="10.0.3.2,10.0.254.254,1h"
LXC_DHCP_MAX="61500"

New container can't get IP with such settings.

Thanks,
Dan



On Fri, Apr 10, 2015 at 3:34 PM, Dan Shi <bruingo at gmail.com> wrote:

> Hi Fajar,
>
> Thanks for the reply! I tried to stop container gracefully (lxc-stop), but
> the IP is not released, I can still find it in
> /var/lib/misc/dnsmasq.lxcbr0.leases.
>
> However, the IP assignment does get cleaned up after a while (once a day?)
> it seems to be controlled by lease time, maybe default to 24 hours. I will
> look into that.
>
> Thanks,
> Dan
>
>
> On Thu, Apr 9, 2015 at 3:39 PM, Fajar A. Nugraha <list at fajar.net> wrote:
>
>> 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
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20150410/68dd4722/attachment.html>


More information about the lxc-users mailing list