By default, lxd containers get random ip from lxd-bridge system. If you want to assign static IPs (i.e with some logical or arithmetic order), good news: It is quite simple.

All we need to do is create a DNS configuration file and tell lxd to use it.

There is a configuration file lxd-bridge under /etc/default/ directory. It is created when you first run lxd init command. It is something like this:

# WARNING: This file is generated by a debconf template!  
# It is recommended to update it by using "dpkg-reconfigure -p medium lxd"

# Whether to setup a new bridge or use an existing one  
USE_LXD_BRIDGE="false"# Bridge name

# This is still used even if USE_LXD_BRIDGE is set to false  
# set to an empty value to fully disable
LXD_BRIDGE="" # Update the “default” LXD profile  

UPDATE_PROFILE="true"# Path to an extra dnsmasq configuration file  

LXD_CONFILE="" # DNS domain for the bridge  

LXD_DOMAIN="lxd" # IPv4

## IPv4 address (e.g.

## IPv4 netmask (e.g.  

Look that LXD_CONFILE. It is empty by default. We are going to put our configuration file’s path here. Let’s say we have 3 containers:

  • web_server
  • web_apps
  • sip_server

Now create a file named dns.conf under /etc/default/ directory:

$ sudo nano /etc/default/dns.conf

Put these lines in it:


The syntax is dhcp-host=container_name,ip_address.

Now update /etc/default/lxd-bridge file:

## Path to an extra dnsmasq configuration file  

That’s it. To make our changes work, we need to restart lxd-bridge service:

$ sudo service lxd-bridge restart

We may need to reboot each container to take their new ip address:

$ lxc exec web_server /bin/bash  
root@web_server:$ reboot

Now each container will have static ip based on our dns.conf file even if you reboot the system.