Windows NIC Teaming using PowerShell (Part 5)

by [Published on 17 Dec. 2013 / Last Updated on 17 Dec. 2013]

This article shows how to implement Windows NIC Teaming in a virtual machine using Windows PowerShell.

If you would like to read the other parts in this article series please go to:

So far in this series of articles we have covered what Windows NIC Teaming is, how it works, what scenarios it supports, what considerations are important when implementing it, and how to implement on a physical server using Windows PowerShell. In this article and the next one we will examine how to implement Windows NIC Teaming on a virtual machine running on a Hyper-V host.

Host configuration

We'll begin by examining the configuration of our host system. As described in the previous article, the server I'm using for this series of articles is an old Dell T300 system that has two built-in Broadcom GbE network adapters. Both of these adapters are connected to the same network subnet in my test lab, and the subnet is connected to the Internet via a router. The server is named HOST30 and the host operating system is Windows Server 2012 R2.

The Hyper-V role has been added to the host and four Hyper-V virtual switches have been created on the host. We can use the Get-VMSwitch cmdlet to view details about these four virtual switches:

PS C:\> Get-VMSwitch
Name    SwitchType NetAdapterInterfaceDescription
----    ---------- ------------------------------
vSwitch-2  External  Broadcom NetXtreme Gigabit Ethernet #2
vSwitch-1  External  Broadcom NetXtreme Gigabit Ethernet
vSwitch-INT Internal
vSwitch-PRI Private

As you can see from the above, the two Broadcom network adapters are connected to external virtual switches so they can provide connectivity with the Internet. The third virtual switch is configured as an internal switch, and the fourth one is configured as a private switch.

To find out what virtual machines are on the host, we can use the Get-VM cmdlet like this:

PS C:\> Get-VM

Name                 State  CPUUsage(%) MemoryAssigned(M) Uptime  Status
----                      -----  -----------             -----------------               ------  ------
DC-150  Off          0      0                     00:00:00 Operating normally
SRV-160  Off        0      0                     00:00:00 Operating normally
SRV35   Running 0      2048              00:04:12 Operating normally
Win81test Saved  0      0                    00:00:00 Operating normally

The virtual machine we will be focusing on is SRV35 which is currently started on the host. The guest operating system of this virtual machine is also Windows Server 2012 R2.

By using the Get-VMNetworkAdapter from the host, we can display information about the virtual network adapters in virtual machine SRV35 as follows:

PS C:\> Get-VMNetworkAdapter -VMName SRV35 | Format-Table Name, SwitchName, MacAddress, IPAddresses -AutoSize

Name      SwitchName MacAddress  IPAddresses
----      ---------- ----------  -----------
Network Adapter vSwitch-1  00155D0B1E09 {172.16.11.64, fe80::6032:6243:2621...
Network Adapter vSwitch-2  00155D0B1E0B {172.16.11.65, fe80::1822:c8ea:e7b8...
Network Adapter vSwitch-INT 00155D0B1E0C {169.254.22.148, fe80::99d:1de1:a66...
Network Adapter vSwitch-PRI 00155D0B1E0D {169.254.225.244, fe80::a07d:228c:7...

As you can see from the above, the virtual machine SRV35 has four virtual network adapters configured with each adapter connected to a different virtual switch on the host.

Virtual machine configuration

Let's examine the network configuration of the virtual machine more closely. After logging on to the guest operating system of the virtual machine we can use the Get-NetAdapter cmdlet to display more info about the virtual network adapters in the virtual machine:

PS C:\> Get-NetAdapter

Name              InterfaceDescription          ifIndex Status
----                   --------------------                    ------- -----
Ethernet 4        Microsoft Hyper-V Network Adapter #4     30 Up
Ethernet 3        Microsoft Hyper-V Network Adapter #3     26 Up
Ethernet 2        Microsoft Hyper-V Network Adapter #2     22 Up
Ethernet         Microsoft Hyper-V Network Adapter      12 Up

As you can see the four virtual network adapters are named Ethernet through Ethernet 4.

The Get-NetIPInterface cmdlet shows that all four virtual network adapters have their IP addresses configured via DHCP:

PS C:\> Get-NetIPInterface -InterfaceAlias "Eth*" -AddressFamily IPv4 | Format-Table InterfaceAlias,Dhcp -AutoSize

InterfaceAlias  Dhcp
--------------  ----
Ethernet 4   Enabled
Ethernet 3   Enabled
Ethernet 2   Enabled
Ethernet    Enabled

And the Get-NetIPAddress cmdlet shows us the IP address that has been dynamically assigned to each virtual network adapter:

PS C:\> Get-NetIPAddress -InterfaceAlias "Eth*" -AddressFamily IPv4 | Format-Table InterfaceAlias,IPAddress,PrefixLength -AutoSize

InterfaceAlias IPAddress         PrefixLength
--------------     ---------                ------------
Ethernet 4   172.16.11.65         24
Ethernet 3   169.254.22.148    16
Ethernet 2   169.254.225.24   16
Ethernet    172.16.11.64    
     24

By comparing the IP addresses in the output from running Get-NetIPAddress in the virtual machine with the IP addresses in the output from running Get-VMNetworkAdapter on the host, we can determine which virtual switch each virtual network adapter is connected to. The table below summarizes this information:

Name of   virtual network adapter

Virtual   switch assigned to adapter

Type of   virtual switch

Ethernet

vSwitch-1

External

Ethernet 2

vSwitch-PRI

Private

Ethernet 3

vSwitch-INT

Internal

Ethernet 4

vSwitch-2

External

 Table 1

We'll need this information soon.

Enabling NIC Teaming for the virtual machine

With physical servers that have multiple physical network adapters, you can simply use the New-NetLbfoTeam cmdlet to create a new NIC team. With virtual machines however, you need to enable NIC Teaming functionality on the virtual machine before you can create a new team from its virtual network adapters.

From the host, we'll start by using the Get-VMNetworkAdapter cmdlet to determine whether NIC Teaming is enabled or not on virtual machine SRV35:

PS C:\> Get-VMNetworkAdapter -VMName SRV35 | Format-Table MacAddress,SwitchName,AllowTeaming -AutoSize

MacAddress  SwitchName AllowTeaming
----------  ---------- ------------
00155D0B1E09 vSwitch-1      Off
00155D0B1E0B vSwitch-2      Off
00155D0B1E0C vSwitch-INT     Off
00155D0B1E0D vSwitch-PRI     Off

From the above we can see that the AllowTeaming parameter is set to Off for each of the four virtual network adapters configured in the virtual machine. To enable NIC Teaming for these adapters, we can use the Set-VMNetworkAdapter cmdlet like this:

PS C:\> Set-VMNetworkAdapter -VMName SRV35 -AllowTeaming On

Let's use Get-VMNetworkAdapter to verify the result:

PS C:\> Get-VMNetworkAdapter -VMName SRV35 | Format-Table MacAddress,SwitchName,AllowTeaming -AutoSize

MacAddress  SwitchName AllowTeaming
----------  ---------- ------------
00155D0B1E09 vSwitch-1       On
00155D0B1E0B vSwitch-2       On
00155D0B1E0C vSwitch-INT      On
00155D0B1E0D vSwitch-PRI      On

NIC Teaming has been enabled on each virtual network adapter, so we're now ready to create a new team.

Creating a new team

From here on we're going to be running all PowerShell commands in the guest operating system of the virtual machine. Let's start by checking if there are any NIC teams in the virtual machine:

PS C:\> Get-NetLbfoTeam

The null output indicates there are no teams yet in the virtual machine.

Let's create a new team using two of the virtual network adapters: Ethernet and Ethernet 4. From the table earlier in this article, you can see that both of these virtual network adapters are connected to external virtual switches on the underlying host. We can use the New-NetLbfoTeam cmdlet to create the new team, but first let's verify we've got things right by using the -WhatIf parameter:

PS C:\> New-NetLbfoTeam -Name VMTestTeam -TeamMembers "Ethernet","Ethernet 4" -WhatIf

What if: Creates Team:'VMTestTeam' with TeamMembers:{'Ethernet', 'Ethernet 4'},TeamNicName...

Now let's run the command:

PS C:\> New-NetLbfoTeam -Name VMTestTeam -TeamMembers "Ethernet","Ethernet 4"

Confirm
Are you sure you want to perform this action?
Creates Team:'VMTestTeam' with TeamMembers:{'Ethernet', 'Ethernet 4'},TeamNicName...
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y

Name          : VMTestTeam
Members        : {Ethernet 4, Ethernet}
TeamNics        : VMTestTeam
TeamingMode      : SwitchIndependent
LoadBalancingAlgorithm : TransportPorts
Status         : Degraded

The new team has been created, but it's status is displayed as Degraded. But if you recall from the previous article in this series, what's likely happening here is that this is only a temporary condition as the new team takes a few seconds to initialize. If we open the NIC Teaming user interface at this point we can verify that the team is properly functioning. A quick way of opening the NIC teaming UI is to type the following command:

PS C:\> lbfoadmin

Image
Figure 1: A new NIC team with two members: Ethernet and Ethernet 4

By selecting Team Interfaces under Adapters and Interfaces, we can also view the interfaces for the new team:

Image
Figure 2: The interfaces for the new NIC team

Everything looks good with the new team, and we can also use PowerShell to verify its status and the details of its team members and team interfaces:

PS C:\> Get-NetLbfoTeam

Name          : VMTestTeam
Members        : {Ethernet 4, Ethernet}
TeamNics        : VMTestTeam
TeamingMode      : SwitchIndependent
LoadBalancingAlgorithm : TransportPorts
Status         : Up

PS C:\> Get-NetLbfoTeamMember -Team VMTestTeam

Name          : Ethernet 4
InterfaceDescription  : Microsoft Hyper-V Network Adapter #4
Team          : VMTestTeam
AdministrativeMode   : Active
OperationalStatus    : Active
TransmitLinkSpeed(Gbps) : 10
ReceiveLinkSpeed(Gbps) : 10
FailureReason      : NoFailure

Name          : Ethernet
InterfaceDescription  : Microsoft Hyper-V Network Adapter
Team          : VMTestTeam
AdministrativeMode   : Active
OperationalStatus    : Active
TransmitLinkSpeed(Gbps) : 10
ReceiveLinkSpeed(Gbps) : 10
FailureReason      : NoFailure

PS C:\> Get-NetLbfoTeamNic -Team VMTestTeam

Name          : VMTestTeam
InterfaceDescription  : Microsoft Network Adapter Multiplexor Driver
Team          : VMTestTeam
VlanID         :
Primary         : True
Default         : True
TransmitLinkSpeed(Gbps) : 20
ReceiveLinkSpeed(Gbps) : 20

In the next article we'll see what else we can do with a NIC team in a virtual machine.

If you would like to read the other parts in this article series please go to:

Advertisement

Featured Links