Wednesday, November 27, 2013

Configuring Management VLAN in Hyper-V 2012 Core using Powershell

While configuring some Hyper-V 2012 core servers this week, I came across a bunch of issues trying to configure VLAN tagging on the management network. My goal was to configure the environment as follows:

Switch Port Configurations:
-2 ports to the Hyper-V host
-trunk ports
-native VLAN 1
-Management VLAN 28
-various other VLANs for VM traffic

Hyper-V Host Configurations:
-NIC Teaming
-Host IP on management VLAN
-1 VMswitch

Once the OS was installed and all the drivers were added, begin by teaming the NICs. Since there is no GUI in Hyper-V core, copy LbfoAdmin.exe and LbfoAdminLib.dll onto the server and run the executable to team the NICs.

Next, open up a command prompt. Identify the name of the virtual adapter for your NIC Team:

Create the VMswitch:
New-VMSwitch -AllowManagementOS 0 -Name "vSwitch" -NetAdapterName "<VirtualAdapterName>"

Create a management adapter and add it to the newly created VMswitch:
Add-VMNetworkAdapter -ManagementOS -Name "Management" -SwitchName "vSwitch"

Tag the VLAN ID to the management adapter:
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName "Management" -Access -VlanId 28

Configure the IP of the management adapter:
New-NetIPAddress -InterfaceAlias "vEthernet (Management)" -IPAddress x.x.x.x -PrefixLength # -DefaultGateway x.x.x.x

The management interface should now be pingable.

Credits to Eric Siron.

1 comment:

  1. nice guide. short and sweet. Any ideas on how to get this automated when using MDT?