Connect to a VLAN Easily

I have covered connecting to a VLAN before on the channel using Netplan and also using LXD profiles in Ubuntu. This tutorial addresses how to connect Windows 11 to a VLAN using the Hyper-V Virtual switch manager which is a part of the Hyper-V Virtual Machine hypervisor. I also cover how to do the same thing in Ubuntu using nm-connection-editor and also the command line.

First Windows:

If you have not installed Hyper-V on your Windows 10/11 you should go into “windows features”, “turn windows features on and off” and enable Hyper-V so that it is installed on your Windows System.

In the tutorial we use Hyper-V Virtual switch manager to create a new external switch that uses your existing Ethernet device, but creates a virtual switch for VLAN30 in my case.

Hyper-V Virtual Switch Manager is found in the “Actions” menu in the right-most panel of Hyper-V Manager.
image

Here is where I created a new external virtual switch named “VLAN30” in Virtual Switch Manager:

image

Although the device was created, we needed a reboot before it appeared and received a DHCP address.

UBUNTU:

In ubuntu we installed vlan support:

sudo apt install vlan

I created a new VLAN adapter in Ubuntu by launching nm-connection-editor from the command line.
image

After clicking “create” I entered the necessary info. Note that your parent interface will differ.
image

You can create multiple VLAN adapters by repeating the above process.

Also of importance might be having the simple command line commands to add and remove a VLAN in case you are on a server and do not have the GUI interface.

To create the VLAN30 interface from the command line:

sudo ip link add link enp1s0 name vlan30 type vlan id 30

You must then bring the interface online:

sudo ip link set dev vlan30 up

Finally, in order to have the new interface get an IP address from your DHCP server on your VLAN:

sudo dhclient vlan30

You can then examine the interface and see it online:

ifconfig 

or

ip a

To remove the Interface:

sudo ip link set dev vlan30 down
sudo ip link delete vlan30