Okay, so i gave it an hour or two of best guess trial and error and got to a point that i have a workable setup with the desired VLAN isolation. I still don’t understand if this is in any sense the “right” way to do it, so i am not marking this as solved in case someone wishes to discuss this with me here. It might also be of use to someone else who is struggling with similar issues.
The configs below are missing proper DNS settings and such on purpose to be added later once i am sure i don’t need to redo all this again. The only base thing i couldn’t figure out now is how to have Incus fully set up a second instance NIC like the first one, but i think i can work around it by having Incus configure the first and attach a second unconfigured NIC, which is then configured inside the container by Ansible down the line (the final plan would be to have Ansible create the containers anyway in the future, so it’s not going against my aim to limit configuration sprawl).
I’m not sure if this makes any sense either, but the only way i was able to get the instance NIC on a VLAN and have Incus set it’s IP address was to use Docker OCI images instead of the images that come from the default image repo (example images:alpine/3.24 vs. docker:library/alpine:latest). I didn’t think to mention it before, but i plan to run mainly Alpine Linux system containers, not application containers in that sense. Doesn’t seem to affect the end result though, i can install packages on and interact with the instance spawned from the OCI image just like the one from the Incus repo.
incus remote add docker https://docker.io --protocol=oci --public
My IncusOS network config:
incus admin os system network show
WARNING: The IncusOS API and configuration is subject to change
config:
dns:
domain: ""
hostname: ""
nameservers:
- 1.1.1.1
interfaces:
- addresses:
- 10.20.2.1/16
hwaddr: 10:e7:c6:ac:18:5e
name: eno1
required_for_online: "no"
roles:
- instances
- management
routes:
- to: 0.0.0.0/0
via: 10.20.0.1
vlan_tags:
- 10
- 20
- 30
time:
timezone: Europe/Helsinki
My Incus network:
incus network show eno1
config: {}
description: ""
name: eno1
type: bridge
used_by: []
managed: false
status: ""
locations: []
project: default
My Incus profiles:
incus profile show default
config: {}
description: Default Incus profile
devices:
root:
path: /
pool: local
type: disk
name: default
used_by:
- /1.0/instances/ct-vlan-test
project: default
incus profile show networking-eth0-vlan30
config: {}
description: ""
devices:
eth0:
name: eth0
nictype: bridged
parent: eno1
type: nic
vlan: "30"
name: networking-eth0-vlan30
used_by:
- /1.0/instances/ct-vlans-test
project: default
incus profile show networking-eth1-vlan10
config: {}
description: ""
devices:
eth1:
name: eth1
nictype: bridged
parent: eno1
type: nic
vlan: "10"
name: networking-eth1-vlan10
used_by:
- /1.0/instances/ct-vlans-test
project: default
What happens if i try to launch an instance with two NICs directly configured by Incus:
incus launch docker:library/alpine:latest ct-vlans-test
--profile default
--profile networking-eth0-vlan30
--profile networking-eth1-vlan10
--device eth0,ipv4.address=10.30.0.55/16
--device eth0,ipv4.gateway=10.30.0.1
--device eth1,ipv4.address=10.10.0.55/16
--device eth1,ipv4.gateway=10.10.0.1
Launching ct-vlans-test
Error: Failed instance creation: Failed to run: /opt/incus/bin/incusd forklxc ct-vlans-test /var/lib/incus/containers /run/incus/ct-vlans-test/lxc.conf /var/lib/incus/logs/ct-vlans-test: exit status 1
And finally, how i managed to launch an instance with two NICs but avoiding the former issue by dropping the second NIC configuration, which results in it successfully requesting a DHCP lease from elsewhere (would prefer to leave it totally unconfigured, but this is passable):
incus launch docker:library/alpine:latest ct-vlans-test
--profile default
--profile networking-eth0-vlan30
--profile networking-eth1-vlan10
--device eth0,ipv4.address=10.30.0.55/16
--device eth0,ipv4.gateway=10.30.0.1
incus exec ct-vlans-test ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
85: eth0@if86: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 9000 qdisc noqueue state UP qlen 1000
link/ether 10:66:6a:97:b6:10 brd ff:ff:ff:ff:ff:ff
inet 10.30.0.55/16 brd 10.30.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::1266:6aff:fe97:b610/64 scope link
valid_lft forever preferred_lft forever
87: eth1@if88: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 9000 qdisc noqueue state UP qlen 1000
link/ether 10:66:6a:d6:8a:6e brd ff:ff:ff:ff:ff:ff
inet 10.10.100.41/16 brd 10.10.255.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::1266:6aff:fed6:8a6e/64 scope link
valid_lft forever preferred_lft forever