Connect network to bridge interface?

I have an instance connected to a network, and here is the profile I use to start it.

$ lxc profile show mylan
config: {}
description: ""
devices:
  root:
    path: /
    pool: default
    type: disk
  mylan:
    name: enp5s0
    network: mylan
    type: nic
name: myprofile
used_by:
- /1.0/instances/node1

And here is mylan.

$ lxc network show mylan
config:
  ipv4.address: none
  ipv4.firewall: "false"
  ipv6.address: none
  ipv6.firewall: "false"
  security.acls: internet
  security.acls.default.egress.action: allow
  security.acls.default.ingress.action: allow
description: ""
name: mylan
type: bridge
used_by:
- /1.0/instances/node1
- /1.0/profiles/myprofile
managed: true
status: Created
locations:
- none

Now I would like to connect this LXD network (mylan) to br0 running on my host machine so that it has internet access.

Is there a way to add this to the profile? Or is there a better way. I will have many instances so would like to not have to modify each one.

Instead of connecting the mylan network to br0, you can just connect the instance NIC directly to br0, e.g.

In the profile devices change to:

  mylan:
    name: enp5s0
    nictype: bridged
    parent: br0
    type: nic

I see you’re point with that, but the instance needs to stay connected to mylan as it’s sort of a test network I have in place. The only reason I want to connect mylan to br0 is temporary just so I can update the instances on the mylan network with other packages using apt, and then I would disconnect the instances from internet access.

Create a profile to connect to br0 as tomp has shown but with a different name. The instance will have a second nic interface and while it’s connected, you’ll have internet access.

Remove the profile to disconnect from br0. You might need to configure netplan or some other way to set DHCP on the second nic if it’s not automatic.

1 Like