How to limit DHCP range for LXD bridge


When I initialize LXD (“lxd init”) I defined the network for lxdbr0, but I want to change the DHCP range from to I know this is managed by dnsmasq…can I use brctl or is there another tool?

$ ps -ef | grep lxdbr0
[output formatted for readability]

dnsmasq --strict-order --bind-interfaces
  --except-interface=lo --no-ping
  --quiet-dhcp --quiet-dhcp6 --quiet-ra
  --dhcp-range,,1h      <---- WHERE/HOW TO EDIT THIS? Want to limit DHCP range to
  -s lxd -S /lxd/
  -u lxd

Thank you,

lxc network edit lxdbr0
and adding a ipv4.dhcp.ranges key should do the trick, as per this doc or this one
What the docs in either version don’t say is what happens when you have already existing containers with IP address outside of the new range. I’d try to avoid it to stay on the safe side.

@gpatel-fr You are absolutely right, that is the answer. Here is the command:

lxc network set lxdbr0 ipv4.dhcp.ranges

I have a bunch of containers already running that have IP addresses above 200 and their IPs have not yet changed… I suppose they will after I restart them, though I don’t know how that is going to impact the applications I have running on them.

Thank you for your reply.

Maybe. Or not. FYI, the leases are under
for SNAP lxd. If containers don’t want to change IPs, you could try to stop them, delete the container entries, and restart them.

The LXD containers grabbed a new IP address in the specified range when the DHCP lease was up, which is set to 1 hour by default (no need to restart any services). Everything appears to be OK, including the application (OpenStack) running inside the containers.

Thanks again.