Recently i ended up in a corner case where I needed to bridge a VM in Virtualbox in a different VLAN than my Host Machine. This is how I accomplished it.
Step 1: Switch Configuration
The switchport needs to be a tagged port with the untagged VLAN matching the VLAN dedicated to the Host Machine. This is an example config from a Cisco Switch:
interface GigabitEthernet0/2
description Desktop
switchport trunk allowed vlan 10,120
switchport trunk native vlan 10
switchport mode trunk
Note: Allowed VLAN list is optional
Step 2: Edit Netplan
Assumption is that networkd is being used rather than Network Manager. Here is the complete configuration for clarity:
network:
version: 2
renderer: networkd # Netplan instead of NetworkManager
ethernets:
eno1: #Check what interfaces are called with "ip add"
dhcp4: yes
dhcp6: no
accept-ra: yes #Enable SLAAC
ipv6-privacy: yes #Enable IPv6 Privacy Extension
vlans:
vlan.120:
id: 120
link: eno1
Note: you could add addresses, routes or whatever you want under the VLAN. It’s just not relevant in my use-case.
Step 3: Edit the VM Network Settings
Now you can choose vlan 120 as the bridged network
Source: https://askubuntu.com/questions/992428/netplan-with-multiple-vlans-on-single-interface-help-needed
Appendix
This was the goal all along:
Enable copy/paste clipboard content from Host-OS to Guest-OS and vice-versa: