Share via


How to delete a VLAN on a Hyper V?

Question

Thursday, December 10, 2015 5:34 PM

I mistakenly put on a VLAN interface 0 interface of my Hyper V server instead of 1. Therefore the mangement no longer works.

I made the change from the Hyper V Manager master server, I only have access to the slave machine with a console.

How can I delete the VLAN and restore my old configuration?

All replies (5)

Thursday, December 10, 2015 9:42 PM ✅Answered

It sounds like you created a virtual switch to be shared between the guests and the host operating system.  If this is the case, you need access to the console of the physical machine on which you created the virtual switch. By misconfiguring the VLAN, you effectively removed network access.  Once on the host's console, you can set the VLAN properly.

I know it's a painful way to learn, but that is one of the reasons it is recommended to always have separate NICs for the physical host and for VM access.  If you mess up the VM access you should still have access to host and then use Hyper-V manager to correct the problems with the VM.

. : | : . : | : . tim


Friday, December 11, 2015 4:26 PM ✅Answered

Set-NetAdapter does have a -VlanID parameter, so you can set physical adapter VLANs on 2012+. I have never used that parameter, ever, so I can't speak to its efficacy. If you just want to set it to VLAN 1, that should be pretty straightforward:

Set-NetAdapter -Name <AdapterName> -VlanID 1

If you want to clear VLAN tagging altogether, that's not as clear.

I share in Tim's confusion as to whether you're talking about a physical or a virtual adapter, though. If you need access to the Set-VMNetworkAdapterVlan cmdlet, then you'll need to install the Hyper-V cmdlets with:

Add-WindowsFeature -Name Hyper-V-PowerShell

With that done, you clear VLAN tagging for a virtual adapter in the management operating system with:

Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName <vnicname> -Untagged

You set a VLAN tag with:

Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName <vnicname> -Access -VlanId 1

If you don't know the necessary names, these cmdlets should prove helpful:

Get-NetAdapter
Get-VMNetworkAdapter -ManagementOS

Eric Siron
Altaro Hyper-V Blog
I am an independent blog contributor, not an Altaro employee. I am solely responsible for the content of my posts.


Friday, December 11, 2015 6:09 AM

Hi Data781,

Agree with Tim.

You need to change the setting through Hyper-V manager of Hyper-V host.

Since you could not manage remotely now, you may need to access the physical machine.

Best Regards,

Leo

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected].


Friday, December 11, 2015 8:59 AM

Hello

In fact I have two separate cards, one for management, one for the VMs. However I was wrong on my card configuration.

Can you tell me the commands to type? It does not recognize Set-VMNetworkAdapterVlan


Friday, December 11, 2015 2:49 PM

Something is not making sense here.  If you have two separate NICs, and you set the VLAN wrong on the NIC for the host, that implies that you used the NIC vendor's configuration utility to set the VLAN on the host's NIC.  There is nothing within Windows Server or Hyper-V that sets the VLAN on the physical NIC. (Well, technically, if the NIC vendor has exposed the VLAN setting via WMI, you could use WMI to set it on the host.)

The only way that you could have set the VLAN with Hyper-V is if you used Hyper-V to configure the host management NIC as a virtual switch to be shared between the host and guests. 

We must be missing something in your problem explanation.

. : | : . : | : . tim