You are here

VLAN Setup on Network Switch and 1 Cable to Computer

1 post / 0 new
NA7RF
VLAN Setup on Network Switch and 1 Cable to Computer
I want to share some of the work I have been doing at my location.  There are 2 projects I have been working on.  One is with an Arduino that has a network shield and relays (I will save this one for another day).  The other project is working with VLANS.  Most of this was because the driver for my NIC in Windows 11 has removed the ability to specify a VLAN.  I want to share the details how I got around this limitation and in doing so, I discovered Hyper-V Virtual Ethernet Adapters.

The first goal was to be able to specify and change the VLAN my NIC was using.  This way, I don't have to disconnect the NIC any time I want to switch between my local network and the Mesh network.  In the end, I found a way to use the one NIC and connect to both networks at the same time.

Here is my setup:
Dell laptop (older one)
Intel I219-LM NIC (built into the laptop)
Cisco SG250-08 smart switch
AREDN Node

The first part is how the Cisco switch is setup.  I am looking to add a second node, so you will see the possibility for an extra node.  This can be replicated with any smart switch; you will need to adjust the terms to whatever your smart switch uses.
Key: T = Tagged, U = Untagged
Port1 - 1T, 2T, 2001U
Port2 - 1T, 2T, 2001U
Port3 - 1T, 2T, 2001U
Port4 - 1T, 2T, 2002U
Port5 - 1T, 2T, 2002U
Port6 - 1U, 2001-2002T
Port7 - 1U, 2001-2002T
Port8 - 1U

Ports 1-3 talk together with no VLAN tagging.
Ports 4-5 talk together with no VLAN tagging.
Ports 6-8 talk together with no VLAN tagging.
I have reserved port8 to manage the smart switch, which is why there are no other VLANs configured on that port.

I have my node in port1 and my home network in port8.  My laptop is connected in port6.

Natively, the laptop is able to get an IP address (DHCP) from my home network.  If I switched it to port2 or port3, it would be on the AREDN network, but I want it to stay on port6.

First is some installations that are needed in Windows 11.  I went to Control Panel (not settings), and then into Programs and Features.  On the left hand side, I went into Turn Windows features on or off.  In the Windows Feature window, I enabled all of Hyper-V.  I know I needed Hyper-V Module for Windows PowerShell and something else.  It was late so I just enabled everything.

Once installed, I needed to configure Hyper-V and I choose to use PowerShell.  All powershell commands were performed as an Administrator.  First I had to find the name of my NIC by using get-netadapter.  The name for my NIC is Ethernet.  On some systems I manage, this has been renamed.  Using the get-netadapter is the best way to find the name of your NIC.

Now I created a virtual switch using this command: new-vmswitch -name vLanSwitch -NetAdapterName Ethernet -AllowManagementOS $true
Note that I substitued the name of my NIC after -NetAdapterName.  This will also be the virtual NIC with no VLAN assigned (using the untagged VLAN).

I then created another virtual NIC adapters using add-vmnetworkAdapter -ManagementOS -Name VLAN2001 -SwitchName vLanSwitch
I used VLAN2001 as the name so that I understood what VLAN that NIC is part of.  You can name it whatever you want.  The SwitchName needs to match the name you created in the previous step.

With the VLAN2001 NIC created, we need to assign it to the correct VLAN using set-vmnetworkadaptervlan -vmnetworkadaptername VLAN2001 -vlanid 2001 -access -managementos 

Once I connected the one ethernet cable between the computer and the smart switch, I received an IP on both AREDN and my home networks.  If I change to another network that doesn't have a 2001 VLAN, I can disable the VLAN2001 NIC or just let it get a 169.254.x.x address.

For the Linux and Mac users, this post is not for you but I bet there is something similar for you as well.  I want to find out how to do it with my OrangePi so I don't have to have 2 NICs on it.

Has anyone else setup their computer like this?
Should I disable/remove this setup and if so, why?

73,
Matt
NA7RF

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer