Copiado na solução como resposta, como eu perdi na primeira vez que olhei para isso (nos comentários) Crédito para @ user4124, marcado como wiki da comunidade.
Instale o LXD (somente host)
sudo apt remove --purge lxd lxd-client && apt install bridge-utils
sudo snap install lxd
sudo reboot
sudo lxd init
Durante a instalação, não crie uma ponte de rede.
Configurar rede para host
sudo nano /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: no
dhcp6: no
bridges:
br0:
dhcp4: no
dhcp6: no
interfaces:
- enp1s0
addresses: [ 192.168.0.2/24 ]
gateway4: 192.168.0.1
nameservers:
addresses:
- 192.168.0.1
- 8.8.8.8
- 8.8.4.4
parameters:
stp: false
forward-delay: 0
sudo netplan --debug apply
Reinicie e confirme se a configuração está correta:
sudo reboot
ifconfig -a
ping google.com
Edite o perfil padrão para garantir que somente a bridge esteja presente na configuração, sem nenhum nic \ extra
sudo lxc profile show default // add '> out.yaml' to output to file
sudo lxc profile edit default // add '< out.yaml' to read from file
Exemplo out.yaml:
### This is a yaml representation of the profile.
### Any line starting with a '# will be ignored.
###
### A profile consists of a set of configuration items followed by a set of
### devices.
###
### An example would look like:
### name: onenic
### config:
### raw.lxc: lxc.aa_profile=unconfined
### devices:
### eth0:
### nictype: bridged
### parent: lxdbr0
### type: nic
###
### Note that the name is shown but cannot be changed
config: {}
description: Default LXD profile
devices:
br0:
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/containers/apache
Configurar rede para contêiner
Executar:
sudo lxc exec <container> bash
nano /etc/netplan/50-cloud-init.yaml
Inserir:
network:
version: 2
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 192.168.0.5/24
gateway4: 192.168.0.1
nameservers:
addresses:
- 192.168.0.1
- 8.8.8.8
netplan --debug apply