How to create a non-nat lxd network bridge (using lxd network)?

networking

(Gregsifr) #1

How to create a non-nat lxd network bridge?

I have tried the below network configs, then ran sudo service networking reload and lxc stop and lxc start for the container in question. I was unable to get the host and the containers to both be on the 10.1.1.1/24 subnet using a non-NAT bridge. When using the default lxdbr0 with NAT everything works fine.

I have tried the below configurations. First without assigning a subnet:

config:
  ipv4.nat: "false"
  ipv6.address: none
description: ""
name: testbr0
type: bridge
used_by:
- /1.0/containers/test
managed: true

The with assigning a subnet:

config:
  ipv4.address: 10.1.1.1/24
  ipv4.nat: "false"
  ipv6.address: none
description: ""
name: testbr0
type: bridge
used_by:
- /1.0/containers/test
managed: true

When to above configurations were used the host lost network connectivity.

How to create a non-nat lxd network bridge (using lxd network)?

I have also posted this question to: https://serverfault.com/questions/907146


#2

You need to make networking changes to the host, by creating the bridge there.
If your host is now on a bridge, then note that it might take quite a few seconds to get ready after you boot up.

The following tutorial shows how to setup LXD with a bridge,
https://blog.simos.info/how-to-make-your-lxd-container-get-ip-addresses-from-your-lan/
The somewhat difficult part is how to set up the host, and in this tutorial I reference a post that shows how to use the NetworkManager GUI.

An alternative to creating a bridge, is to use macvlan.
Here is a tutorial about that,
https://blog.simos.info/how-to-make-your-lxd-container-get-ip-addresses-from-your-lan/
The benefit of macvlan is that you do not need to make networking changes to the host.
The downside of macvlan is that the containers (with LAN IPs) cannot access the host, and that’s related to how macvlan works.

Finally, none of the above will work if your host is connected to the local network over WiFi.