Adding vlan interfaces to LXD VMs

Not sure if this is meant to be supported or not, but I can’t figure out what’s happening here, the green button isn’t clickable and there is no error message to tell me what’s wrong.

What I am trying to do is take a VM that I already created, and add an interface to it with a different VLAN (500) and subnet, both of which have been defined in MAAS and I have added to the rack controller.

Any ideas? Even if this is a UI bug, is this even going to do anything?

The outcome I am looking for is to get it to configure a VLAN subinterface, so if I specified 500 it would use vlan tag 500 from the VM host. Perhaps this is not supported with VMs?

Here is a really ugly picture of what I’m trying to do:

ah, it turns out I need to specify the mac address, it just isn’t highlighting it as the errored field, but when I clicked in there it did show up. So probably a UI bug.

Hi Anton!

No, that won’t do what you would expect it to.

MAAS doesn’t support modifying VMs after they have been created. The way to do it with MAAS would be to delete the VM and recreate it with the interfaces that you want it to have.

Now in order to getting the tagged VLANs as shown in your picture, the VM host needs to be configured in a certain way. I can’t remember exactly what works and what doesn’t, but you could try any of the following two scenarios:

  1. Configure VLAN interfaces on the VM host.

  2. Configure VLAN interfaces on the VM host, and for each VLAN you want to expose to the VMs, create a bridge with the corresponding VLAN interface inside it.
    a) For example: VLAN interface eth0.123 that’s in a vlan123br bridge.

The interfaces inside the VMs will be untagged, but they traffic will be tagged as it leaves the host.

hi @bjornt !

Yep, I am aware the machines would need to be reprovisioned (note, that VM was in “ready” state).

Anyway, if I understand you correctly:

  • configure VLAN interfaces for the VM host to match the VLANs that are desired
  • bridge the VLAN interfaces on the VMs to the corresponding VLAN interface

This second step is where I am confused. Is this to be done on the VM host at the OS level (i.e. log in and do this?), or can it be done when creating the VM inside the MAAS UI? I don’t see it in the UI:

Just uncertain how to tie the VMs to the bridges, and where the bridges should be configured (on reflection, I guess you mean they should be configured on the VM host)?

Untagged inside the VMs is totally fine.

OK so I got this working, thanks to @bjornt and @kevin-reeuwijk and a bit of shoe spit polish.

Here’s a quick diagram of what will get set up:

Here is how I did it:

Preparation

  • I added a VLAN interface to MAAS rack controller, e.g. VLAN 500, and manually added an IP address to it e.g. 150.150.150.1/24
  • I added a subnet and VLAN in MAAS after restarting MAAS (to make sure it saw the new interface for the rack controller). Subnets page looks like this:
  • made sure to enable DHCP on the VLAN:

Set up a VM host with the bridges and VLANs needed

1 - add a VLAN to the physical interface:

Leave IP mode unconfigured.

2 - create a bridge interface with the new VLAN interface as a member:



No need to add any IP address to it here, unless you want to for testing purposes.
In my case I’ve used just one VLAN everywhere, 500. But you would add more bridges and VLANs for each VLAN you’d like to open up for adding VMs to later. I’ve got one, just for demonstration.

Creating VMs

Assuming after this you deployed the machine with VM host enabled, things should be setup just fine now to create VMs.

When creating the VMs, simply specify an interface and select the subnet desired, this results in the VM being in the right VLAN.

diagram of the setup

eagle eyed among you will notice some mistakes on the bridge interface names and colours, I lost the original diagram now, but I think you get the point :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.