Forum Discussion
Hyper-V Core - Setting up a VLAN
Yes, you can set up VLANs on Hyper-V Core 2019 using PowerShell, and your existing VMs can be grouped into a private network with internet access. You don’t need to upgrade to a full GUI OS to achieve this:
1. Create a Virtual Switch
Use PowerShell to create an external virtual switch that supports VLAN tagging:
New-VMSwitch -Name "VLANSwitch" -NetAdapterName "Ethernet" -AllowManagementOS $true
• Replace "Ethernet" with your actual physical NIC name.
• This switch will allow VMs to communicate externally and with each other.
2. Assign VLAN IDs to VM network adapters
For each VM you want to isolate into a VLAN:
Set-VMNetworkAdapterVlan -VMName "VM1" -Access -VlanId 100
Set-VMNetworkAdapterVlan -VMName "VM2" -Access -VlanId 100
...
• This puts all 5 VMs into VLAN 100.
• Use different VLAN IDs for other groups.
3. Enable internet access
To allow internet access:
• Ensure the physical switch port connected to your Hyper-V host is configured as a trunk port.
• Allow VLAN 100 on that trunk.
• Configure NAT or use a virtual router VM (e.g., pfSense) to route traffic from VLAN 100 to the internet.