Lxd container networks

Good morning everyone. This is dash here from South Africa. Thank you for allowing me to participate in your forum.

Just starting out with lxd containers. I know you have one tutorial available for this however, can you point me into some direction where networks are discussed.

1 Like

Hello Dash, welcome to the forum!

I don’t think there’s a lot of documentation about this, however, LXD uses basically the same tool as some hypervisors for networking, which is brctl (I think it’s part of bridge-utils).

You can configure LXD containers in 2 ways: do a NAT on your device and have the containers speak on their own internal subnet, or bridge them to your current subnet and have them speak with the rest of your infrastructure, which is what I prefer, because otherwise, well, you have to port forward services to your LXD host and connect to that, if you want to access a service not from the LXD host.

By default, when you do a lxd init, if you don’t have bridge-utils installed, the configuration will default to NAT-ing. Before you lxd init, install bridge-utils. If you already installed LXD and have containers setup, not to worry, you can just re-run it, or you can manually delete the lxdbr0 (I think that’s what the bridge is called) and set a new one using brctl.

Although those are a bit old, the information in them is still relevant:

https://linuxcontainers.org/lxd/docs/stable-4.0/networks

If you need any more help, feel free to ask. I’m not exactly a LXD guru, but I know more about LXD than I do about OCI containers (like Docker, K8s or Podman), which doesn’t mean much though.

2 Likes