LXD/Laptop Network Setup
When using LXD on a laptop, having LXD manage a bridge will cause a conflict with the default route on your system which is managed by NetworkManager. This will result in your Internet connection failing. See https://bugs.funtoo.org/browse/FL-8295 for more information on the gory details if you are interested. Fortunately, there is a relatively easy way to work around this.
Using an Unmanaged Bridge
LXD can be really useful to use on a laptop, because you can spin up containers locally for development. A bit of manual setup is required but once set up, this configuration should give your containers Internet access regardless of what particular WiFi network you are connected to.
To do this, we are going to set up an unmanaged bridge using Funtoo networking, rather than have LXD create a managed bridge for us.
Create the following file on your laptop:
This will set up a 10.0.30.0/24 network and we are setting up your laptop to be the gateway for this network. We will get the containers to the Internet by connecting your containers to this bridge, and giving them an IP address in the 10.0.30.2 thru 10.0.30.254 range.
Now, let's enable this bridge:
root # cd /etc/init.d root # ln -s netif.tmpl netif.brwan root # rc-update add brwan default root # rc
The bridge is now set up.
Cleaning Up the Mess
It's important to NOT have LXD create a bridge for us.
However, if you have already set up LXD to create a bridge, here is how to clean up the mess.