How to create NIC Teaming using PowerShell in Windows Hyper-v 2012 R2

For this article we will configure the NIC Teaming in your Hyper-V this is only required if you have more than two (2) network connections and this below configuration will be done in your Cisco switch. This example shows how to configure EtherChannel. It uses LACP passive mode and assigns two ports as static-access ports in VLAN 10 to channel 5:

Configuraation for the Management Ports:

Switch# configure terminal 
 Switch(config)# interface gigabitethernet3/0/2
 Switch(config)# switchport mode access
 Switch(config)# switchport access vlan 10
 Switch(config)# channel-group 1 mode active 
 Switch(config)# exit
 Switch(config)# interface gigabitethernet3/0/3 
 Switch(config-if)# switchport mode access
 Switch(config-if)# switchport access vlan 10
 Switch(config-if)# channel-group 1 mode active 
 Switch(config-if)# exit

Configuration for the Data TRUNK Ports

 Switch(config)# interface range gigabitethernet 3/0/4 - 5
 Switch(config-if-range)# channel-group 2 mode on
 Switch(config-if-range)# switchport trunk encapsulation dot1q
 Switch(config-if-range)# switchport mode trunk 
 Switch(config-if-range)# switchport trunk allowed vlan 2,4,10,23
 Switch(config-if)# exit

Step 1: After your switch is configured you can now Login to your Windows Hyper-V 2012 R2  and Launch PowerShell. In one of the the windows MS-DOS mode type below

> start powershell

NICTeampowershell_02

and the powershell windows will open. Note you can do this also if you want to run another MS-DOS by typing “start cmd”

Step 2: First thing we need to identify the Network Adapter names that we will add in the Teaming so we use the command below then hit enter

Get-NetAdapter

*Note: Make sure you know which NIC ports will be joining in Teaming if you have multiple NIC card for this blog as I’m using HP Blade system I can check the MacAddress of the Blade Server in Virtual Connect under server profiles and will be using this two below to join

XX-XX-XX-XX-04-10
XX-XX-XX-XX-04-14

Step 3: Run the command in your powershell and replace the value for

  • -Name “Your Team name here”
  • -TeamMembers “Ethernet 5″,”Ethernet 2”
  • -TeamingMode LACP
  • -LoadBalancingAlgorithm TransportPorts

change the parameter according to your configurations

New-NetLbfoTeam -Name “NIC_Teamed0” -TeamMembers “Ethernet 5″,”Ethernet 2” -TeamingMode LACP -LoadBalancingAlgorithm TransportPorts -Confirm:$false

NICTeampowershell_05

OR Alternative way is to do like this

New-NetLbfoTeam -Name “NIC_Teamed0”

and enter the Ethernet ports that will be a members for this group then type ‘Y’ to confirm after that you can check the status by typing

Get-NetLbfoTeam

Hyperv2012_17b

*Note: If you ever want to remove the teaming configuration just type the below command

Remove-NetLbfoTeam “NIC_Teamed0”

Step 4: IP address assignment in the Teaming NIC that we just created

New-NetIPAddress -InterfaceAlias “NIC_Teamed0” -AddressFamily IPv4 -IPAddress 192.168.100.14 -DefaultGateway 1.2.3.1 -PrefixLength 24

*Note: The PrefixLength 24 is equivalent to 255.255.255.0

Step 5: Now Configure the DNS

Set-DnsClientServerAddress -InterfaceAlias “NIC_Teamed0” -ServerAddresses “192.168.100.254”,”192.168.101.254″

Step 6: disable the firewall because this is Home Lab its better to disable the firewall 😀

netsh advfirewall set allprofiles state off

NICTeampowershell_08

Step 7: Configure the Data ports that the VMs will be using to connect in your Home Lab network. In this part as I’m also using two network port and running LACP in the network first I configure the Teaming it will be the same procedure in the Step 3 but this time we change the -Name description and -TeamMembers

New-NetLbfoTeam -Name “NIC_Teaming_DATA_TRUNK” -TeamMembers “Ethernet 3″,”Ethernet 4” -TeamingMode LACP -LoadBalancingAlgorithm TransportPorts -Confirm:$false

Step 8: In your Hyper-V Client connection click the “Virtual Switch Manager” as seen in below Image it is located in the rigth side Action Pane Window. And then select the option below then click the “Create Virtual Switch” button

Virtual Switches -> New Virtual Network Switch -> External

Step 9: This is the final steps in creating the virtual switch properties. Give a propername for the vSwitch description.

Under the Extenal Network this is the Teaming that we created in Step 7 to double check you have the correct name go back to your Hyper-V powershell and type the

Get-NetAdapter

NICTeampowershell_14

Step 10: Assign the VLAN ID in the Guest Operating System configuration profile.

Virtual switch -> Enable virtual LAN identification -> VLAN ID

NICTeampowershell_15

Click “Apply” then “OK” to save the configuration and now run the guest VM and configuration the IP’s as per normal configuration of windows OS

 

Be the first to comment on "How to create NIC Teaming using PowerShell in Windows Hyper-v 2012 R2"

Leave a comment

Your email address will not be published.