Best way to manage vlan on IncusOS

Hi,

what is the best way to manage vlan on incusOS.

On my server, I only have 1 nic.

I add a physical interface with role instance on my configuration

incus admin os system edit network

config:
  interfaces:
  - addresses:
    - dhcp4
    - slaac
    hwaddr: bc:24:11:04:dc:4e
    name: ens18
    required_for_online: "no"
    roles:
    - instances
    vlan_tags:
    - 20
    - 10
    - 40
    - 50
  time:
    timezone: UTC
state:
  interfaces:
    ens18:
      addresses:
      - 192.168.99.230
      hwaddr: bc:24:11:04:dc:4e
      mtu: 1500
      roles:
      - instances
      - management
      - cluster

and then add the specific vlan to my instance with a terraform like this:

resource "incus_profile" "iot_vlan20" {
  name = "iot_vlan20"
    device {
    name = "eth0"
    type = "nic"

    properties = {
      nictype = "physical"
      parent  = "ens18"
      vlan    = "20"
    }
  }
}

Is this the right way to do it ? Do you recommend another way ?

Regards,

Edouard

That will work just fine.

Another option is to add an intermediate management physical network in between with something like:

incus network create VLAN20 --type=physical parent=ens18 vlan=20

You can then place an instance on it by using type=nic network=VLAN20 name=eth0

Ok thanks

Can the first change (incus admin os system edit network) be done via terraform ?

yep, through incus_network