Replacing network bridge

LXC 4.0.6 on Debian 11.6

By default “lxd init” created lxcbr0 and veth75a9dcc3@if9 interfaces and assigned some 10.x.x.x subnet to it.

That’s not what I wanted.

I need a transparent simple bridge (no DHCP, no DNSMASQ) with all containers behind using the same subnet as the host and the rest of the LAN (192.168.x.x).

I have a single Ethernet cable plugged into the host to eno1 interface (10 Gbps).

I have created the following bridge manually to /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# Bridged network interface
auto br0
iface br0 inet static
        bridge_ports eno1
        bridge_stp off  # disable Spanning Tree Protocol
        bridge_waitport 0  # no delay before a port becomes available
        bridge_fd 0  # no forwarding delay
        address 192.168.x.x/22
        gateway 192.168.x.x
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.x.x
        dns-search example.com

It comes up after a reboot and seems to be working fine.

Now when I try to replace lxcbr0 with br0 I get:

lxd init
(...)
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: br0
(...)
Error: Failed to update profile "default": Device validation failed for "eth0": Cannot use "nictype" property in conjunction with "network" property

Eth0 seems wrong as I don’t seem to have any such interface on the host.

I’ve also tried “lxc profile edit default”

config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by:
- /1.0/instances/test

I’ve tried replacing eth0 with eno1 or br0 and lxdbr0 with br0 but for everything I’ve tried I’m getting errors:

Config parsing error: Device validation failed for "eth0": Failed loading device "eth0": Failed to load network "br0" for project "default": Network not found

or

Config parsing error: Device validation failed for "eno1": Failed loading device "eno1": Failed to load network "br0" for project "default": Network not found

or

Config parsing error: Device validation failed for "br0": Failed loading device "br0": Failed to load network "br0" for project "default": Network not found

What do I need to do to accomplish my goal and replace or modify my network bridge?

Hi @adamw-ms, here follow that link.
Regards.
https://thenewstack.io/how-to-create-a-bridged-network-for-lxd-containers/

Try changing the NIC config to:

devices:
  eth0:
    name: eth0
    type: nic
    nictype: bridged
    parent: br0

You cannot use the network setting as br0 isn’t a LXD managed network, its an unmanaged parent interface.

See https://linuxcontainers.org/lxd/docs/master/reference/devices_nic/#nictype-bridged

1 Like

It worked like a charm, thank you.

I’m always only going to use br0 on this host. Keeping lxcbr0 looks messy and confusing at the very least. It even has a subnet still assigned:

ip addr
(...)
6: lxcbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 00:16:3e:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.1/24 brd 10.0.3.255 scope global lxcbr0
       valid_lft forever preferred_lft forever
(...)

Shall I be concerned at all about lxcbr0? Is it possible to safely remove it? I’m guessing it cannot be done with lxc since it’s not managed:

lxc network list
+--------+----------+---------+------+------+-------------+---------+-------+
|  NAME  |   TYPE   | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | STATE |
+--------+----------+---------+------+------+-------------+---------+-------+
| br0    | bridge   | NO      |      |      |             | 1       |       |
+--------+----------+---------+------+------+-------------+---------+-------+
| eno1   | physical | NO      |      |      |             | 0       |       |
+--------+----------+---------+------+------+-------------+---------+-------+
| eno2   | physical | NO      |      |      |             | 0       |       |
+--------+----------+---------+------+------+-------------+---------+-------+
| eno3   | physical | NO      |      |      |             | 0       |       |
+--------+----------+---------+------+------+-------------+---------+-------+
| eno4   | physical | NO      |      |      |             | 0       |       |
+--------+----------+---------+------+------+-------------+---------+-------+
| lxcbr0 | bridge   | NO      |      |      |             | 0       |       |
+--------+----------+---------+------+------+-------------+---------+-------+

As you can see from the MANAGED colum in your output, lxcbr0 is not created or managed by LXD.

I suspect this is being configured from the legacy lxc package. You probably need to disable that service.

But it won’t cause an issue if its there anyway.

Fixed by:

apt remove --purge liblxc1 lxcfs

It was actually my bad installing lxc via apt first followed by installation of lxd via snap. Since some duplication and unwanted leftovers.

1 Like