LXD setup - nolt/acore-lxd-image GitHub Wiki

LXD installation

  • check if snapd and LXD is installed
sudo snap list
  • if not type
sudo snap install snapd && sudo snap install lxd
sudo snap list

LXD configuration

lxd inid

For most question asnerw default. Storage can be set up as loop device, but it's highly recommended to use sperate partition or disk as storage pool. If you can't' it's just fine, but be sure you have enough space on mount point "/" because loop device will be created in "/var/snap/lxd/common/lxd/disks/default.img".

  • launching first container
lxc launch ubuntu:focal acserv

  • list your containers
lxc list

  • attach to the container shell
lxc exec acserv bash

Congratulation! Your first container named "acserv" is up and running, you are now attached to it.

Assign new profile to LXD container

With this profile your container will gets LAN IP address.

  • list available profiles in your LXD
lxc profile list

  • create new profile called "macvlan", list all profiles
lxc profile create macvlan
lxc profile list

  • check your network interface name and it's default gateway
ip route show default 0.0.0.0/0
  • in this example mine network interface is called "enp1s0"
  • lets create new network interface called "eth1" in "macvlan" profile
lxc profile device add macvlan eth1 nic nictype=macvlan parent=enp1s0

  • stop the container, assign new profile to container and start the container (it is best to assign both default and newly created macvlan profile to container)
lxc stop acserv
lxc profile assign acserv default,macvlan
lxc start acserv

  • attach to container
lxc exec acserv bash
  • edit container network configuration using your text editor
vim /etc/netplan/50-cloud-init.yaml

  • add another interface called eth1 and set dhcp4 to "true", file should look like this
  • apply new configuration
netplan apply

  • your container should now have two network interfaces
    • eth0 with IP from lxdbr0 DHCP (10.x.x.x)
    • eth1 with IP from your LAN DHCP server (192.168.x.x) to check it just type
ip a
  • you can also check IP addresses using "lxc list" command
lxc list

Last thing to do is to replace IP in realmlist table to your LAN IP.
That's all!