LXD networking: lxdbr0 explained



on 7 April 2016

Recently, LXD stopped depending on lxc, and thus moved to using its own bridge, called lxdbr0. lxdbr0 behaves significantly differently than lxcbr0: it is ipv6 link local only by default (i.e. there is no ipv4 or ipv6 subnet configured by default), and only HTTP traffic is proxied over the network. This means that e.g. you can’t SSH to your LXD containers with the default configuration of lxdbr0.

The motivation for this change mostly to avoid picking subnets for users, because this can cause breakage, and have users pick their own subnets. Previously, the script that set up lxcbr0 looked around on the host’s network, and picked the first 10.0.*.1 address for the bridge that was available. Of course, in some cases (e.g. networks which weren’t visible at the time of bridge creation) this can break routing for users’ networks.

So, if you want to have parity with lxcbr0, you’ll need to configure the bridge yourself. There are a few ways to do this. For a step by step walkthrough of just configuring the bridge, simply do:

sudo dpkg-reconfigure -p medium lxd

And answer the questions however you like. If you’ve never configured LXD at all (and e.g. want to use a fancy filesystem like ZFS), try:

sudo lxd init

Which will configure all of LXD (both the filesystem and lxdbr0). Finally, you can edit the file /etc/default/lxd-bridge and then do a:

sudo service lxd-bridge stop && sudo service lxd restart

For feature parity with lxcbr0, you can use something like the following (note the 10.0.4.*, so as not to conflict with lxcbr0):

# Whether to setup a new bridge or use an existing one

# Bridge name
# This is still used even if USE_LXD_BRIDGE is set to false
# set to an empty value to fully disable

# Path to an extra dnsmasq configuration file

# DNS domain for the bridge

# IPv4
## IPv4 address (e.g.

## IPv4 netmask (e.g.

## IPv4 network (e.g.

## IPv4 DHCP range (e.g.,

## IPv4 DHCP number of hosts (e.g. 250)

## NAT IPv4 traffic

# IPv6
## IPv6 address (e.g. 2001:470:b368:4242::1)

## IPv6 CIDR mask (e.g. 64)

## IPv6 network (e.g. 2001:470:b368:4242::/64)

## NAT IPv6 traffic

# Run a minimal HTTP PROXY server

And that’s it! That’s all you need to do to configure lxdbr0.

Sometimes, though, you don’t really want your containers to live on a separate network than the host because you want to ssh to them directly or something. There are a few ways to accomplish this, the simplest is with macvlan:

lxc profile device set default eth0 parent eth0
lxc profile device set default eth0 nictype macvlan

Another way to do this is by adding another bridge which is bridged onto your main NIC. You’ll need to edit your /etc/network/interfaces.d/eth0.cfg to look like this:

# The primary network interface
auto eth0
iface eth0 inet manual # note the manual here

And then add a bridge by creating /etc/network/interfaces.d/containerbr.cfg with the contents:

auto containerbr
iface containerbr inet dhcp
  bridge_ports eth0

Finally, you’ll need to change the default lxd profile to use your new bridge:

lxc profile device set default eth0 parent containerbr

Restart the networking service (which if you do it over ssh, may boot you :), and away you go. If you want some of your containers to be on one bridge, and some on the other, you can use different profiles to accomplish this.

Original article

Ubuntu cloud

Ubuntu offers all the training, software infrastructure, tools, services and support you need for your public and private clouds.

Sign up for email updates

Choose the topics you're interested in


Related posts

LXD Clusters: A Primer

Since its inception, LXD has been striving to offer a fresh and intuitive user experience for machine containers. LXD instances can be managed over the network through a REST API and a single command line tool. For large scale LXD…

LXD weekly status #44

Introduction Another week of bugfixes for us as more and more people update to the 3.0 releases! Quite a bit of work went into improving the handling of the two database in LXD 3.0, making it easier for us to debug issues and provide fixes…

LXD weekly status #43

Introduction This week’s focus was on bugfixes with a good number of clustering related fixes and improvements as well as some tweaks and fixes to other recently added features. On the feature development front, the current focus is on…