Second NIC inside lxc virtual machine

Here is my config

architecture: x86_64
  image.architecture: amd64
  image.description: ubuntu 20.04 LTS amd64 (release) (20201117)
  image.label: release
  image.os: ubuntu
  image.release: focal
  image.serial: "20201117"
  image.type: disk-kvm.img
  image.version: "20.04"
  volatile.base_image: c395f94bc57888731deeee079afa7bee934a86085c7c96f20cfcbacbbc4c6aa4
  volatile.eth0.host_name: tapf4b8e672
  volatile.eth0.hwaddr: 00:16:3e:38:dd:0b
  volatile.eth1.host_name: tapecc8d1a2
  volatile.eth1.hwaddr: 00:16:3e:c4:44:32
  volatile.last_state.power: RUNNING
  volatile.vm.uuid: 04c4fa95-901f-4c0f-a9c1-9752d480d4c8
devices: {}
ephemeral: false
- default-vm
stateful: false
description: ""

Here is my default-vm

  limits.cpu: "2"
  limits.memory: 4GB
description: Default LXD profile
    name: eth0
    network: lxdbr0
    type: nic
    name: eth1
    nictype: bridged
    parent: br0
    type: nic
    path: /
    pool: default
    size: 50GB
    type: disk
name: default-vm
- /1.0/instances/ubuntu

I added eth1 in the profile, and restart the VM, but nothing happened. Did I do something wrong?


I’ve changed the category to LXD (rather than LXC) and used the backticks to mark the config samples as ‘code’ so they are easier to read.

Onto your question, LXD VM images are configured by default to have network configuration (via DHCP) for a single interface called enp5s0 which translates to the first NIC device (ordered by name of device) added to an instance.

Unlike LXD containers, we cannot setup additional interfaces inside the VM because we cannot modify the network config inside a VM after its been created (we may be able to change this in the future by leveraging lxd-agent’s assistance, but certainly not at this time).

As such when adding an additional NIC device, LXD will effectively just ‘connect’ the NIC to the VM as another PCIe device and then its up to the owner of the VM to configure the network config inside the VM to use it.

If you run lspci inside the VM you should see the 2nd NIC device, and you should also see it in the output of ip link as enp6s0.