Setup a network bridge for your LXC containers with lxc-net
After having played around a bit with LXC and discovered its main features, you may want to have a proper network setup for your containers.
There are multiple network setups possible and multiple ways to implement them. In this post, we are going to setup a bridge, using lxc-net. It requires very little configuration and should be enough for a simple LXC architecture.
More details about this bridge setup:
- Containers will have an IPv4 within their own subnet
- Containers will be able to access each other within this subnet
- The host will be able to access the containers trough this subnet
- Containers will have access to the internet thanks to the bridge interface
Note that I’m using Debian 9 for this tutorial. Also, if you’re using LXD to manage your LXC containers, this isn’t necessary as it does everything automatically.