Table of Contents

Configuring Hyper-V Network Interfaces for Clustering

See also How to Change Current Network Location Profile

http://www.thomasmaurer.ch/2012/05/configure-hyper-v-host-network-adapters-like-a-boss/

Converged Networking

http://www.aidanfinn.com/?p=12588

http://www.altaro.com/hyper-v/teaming-and-mpio-for-storage-in-hyper-v-2012/

In Windows Server 2008 a host with local storage would require the following NICs as a minimum:

  1. Parent (Management)
  2. VM (for the Virtual Network, prior to the Virtual Switch)
  3. Cluster Communications/CSV
  4. Live Migration

As the number of NICs proliferate:

  1. The number/cost of NICs go up
  2. The number/cost of switch ports goes up
  3. The wasted rack space cost goes up
  4. The power bill goes up
  5. The support cost for your network goes up
  6. The complexity goes up

Basic Steps for Identical Hardware

  1. Rename the NICs of the first host
  2. Run the Get-NICInformation.ps1 on the first host and check the NIC order
  3. Edit the networkconfig.xml on the second hosts with the right order of the NICs
  4. Run the Set-IPAddressfromXML.ps1
  5. Do this for all Hyper-V Hosts

Possible Hyper-V NIC Names

With four NICs:

Rename a NIC

netsh interface set interface "Local Area Connection 2" newname="Management"

Get-NICInformation.ps1

# ---------------------------------------------------------------------------------------------- #
# Powershell Get-NICInformation $Rev: 748 $                                                                 
# (c) 2011 Thomas Maurer. All rights reserved.                                              
# created by Thomas Maurer 
# www.thomasmaurer.ch
# www.itnetx.ch                                                                 
# last Update by $Author: tmaurer $ on $Date: 2012-02-24 14:07:36 +0100 (Fr, 24 Feb 2012) $     
# ---------------------------------------------------------------------------------------------- #
 
 
#region [INFO BLOCK]
# INFO
Write-Host "                               " -BackgroundColor Black -ForegroundColor White
Write-Host " PowerShell Get-NICInformation " -BackgroundColor Black -ForegroundColor White
Write-Host "                               " -BackgroundColor Black -ForegroundColor White
Write-Host " by Thomas Maurer              " -BackgroundColor Black -ForegroundColor White
Write-Host " www.thomasmaurer.ch           " -BackgroundColor Black -ForegroundColor White
Write-Host "                               " -BackgroundColor Black -ForegroundColor White
#endregion
 
$adapters = Get-WMIObject Win32_PNPSignedDriver | Where-Object { $_.DeviceClass -eq "NET" -and $_.HardWareID -like "*PCI*" } | Sort-Object location
  
foreach ($adapter in $adapters ) {
  
    $adapterName = Get-WMIObject Win32_NetworkAdapter | Where-Object { $_.PNPDeviceID -eq $adapter.DeviceID }
    $adapterConfiguration = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.index -eq $adapterName.Index }
  
    Write-Host ‘Adapter Name :’ $adapterName.NetConnectionID
    Write-Host ‘PCI BUS :’ $adapter.Location
    Write-Host ‘MAC Address :’ $adapterName.MACAddress
    Write-Host ‘GUID :’ $adapterName.GUID
    Write-Host ‘Adpater Index :’ $adapterName.Index
    Write-Host ‘Hardwarename :’ $adapterName.Name
    Write-Host ‘DHCP enabled :’ $adapterConfiguration.DHCPEnabled
    Write-Host ‘IP Address :’ $adapterConfiguration.IPAddress
    Write-Host ‘Subent :’ $adapterConfiguration.IPSubnet
    Write-Host ‘Default Gateway :’ $adapterConfiguration.DefaultIPGateway
    Write-Host  
  
}

Set-IPAddressFromXML.ps1

# ---------------------------------------------------------------------------------------------- #
# Powershell Set-IPAddressfromXML $Rev: 748 $                                                                   
# (c) 2011 Thomas Maurer. All rights reserved.                                              
# created by Thomas Maurer 
# www.thomasmaurer.ch
# www.itnetx.ch                                                                 
# last Update by $Author: tmaurer $ on $Date: 2012-02-24 14:07:36 +0100 (Fr, 24 Feb 2012) $     
# ---------------------------------------------------------------------------------------------- #
 
#region [INFO BLOCK]
# INFO
Write-Host "                                 " -BackgroundColor Black -ForegroundColor White
Write-Host " PowerShell Set-IPAddressfromXML " -BackgroundColor Black -ForegroundColor White
Write-Host "                                 " -BackgroundColor Black -ForegroundColor White
Write-Host "  done by Thomas Maurer          " -BackgroundColor Black -ForegroundColor White
Write-Host "  www.thomasmaurer.ch            " -BackgroundColor Black -ForegroundColor White
Write-Host "                                 " -BackgroundColor Black -ForegroundColor White
#endregion
 
#region [CONFIG BLOCK]
# Get XML Information
[Xml]$global:xmlData = Get-Content ".\networkconfig.xml"
# Set NIC number starting value
[int]$global:nicNumber = "1"
#endregion
 
#region [MAIN BLOCK]
#Get NIC list
$Adapters = Get-WMIObject Win32_PNPSignedDriver | where { $_.DeviceClass -eq "NET" -and $_.HardWareID -like "*PCI*"} | Sort-Object location
  
foreach ($Adapter in $Adapters ) {
    # Get Adapter Info
    $AdapterName = Get-WMIObject Win32_NetworkAdapter | where { $_.PNPDeviceID -eq $Adapter.DeviceID }
    $nic = $xmlData.config.networkadapters.nic | Where-Object {$_.id -eq $nicNumber}
     
    # Write NIC Info
    Write-Host ‘Adapter Name :’ $AdapterName.NetConnectionID
    Write-Host ‘PCI BUS :’ $Adapter.Location
    Write-Host ‘MAC Address :’ $AdapterName.MACAddress
    Write-Host ‘GUID :’ $AdapterName.GUID
    Write-Host ‘New Name :’$nic.name
    Write-Host
     
    # Change NIC Name
    Invoke-Expression ('netsh interface set interface `"' + $AdapterName.NetConnectionID + '`" newname=`"' + $nic.name + '`" | out-null')
    Write-Host ('netsh interface set interface "' + $AdapterName.NetConnectionID + '" newname="' + $nic.name + '"') -BackgroundColor Green -ForegroundColor Black
     
    # if true set IP Address
    if ($nic.static -eq "true"){
        Invoke-Expression ('netsh interface ipv4 set address `"' + $nic.name + '`" static ' + $nic.ip +' ' + $nic.subnet + ' ' + $nic.gateway + ' | out-null')
        Write-Host ('netsh interface ipv4 set address "' + $nic.name + '" static ' + $nic.ip +' ' + $nic.subnet + ' ' + $nic.gateway) -BackgroundColor Green -ForegroundColor Black
    }
    else {
        Write-Host "No IP set" -BackgroundColor Green -ForegroundColor Black
    }
     
    # Count +1 for next Adapter
    $nicNumber++
}
#endregion

networkconfig.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
  <networkadapters>
    <nic id="1" name="Management" static="true" ip="10.10.1.8" subnet="255.255.255.0" gateway="10.10.1.1" />
    <nic id="2" name="GuestPublic" static="true" ip="10.10.5.8" subnet="255.255.255.0" gateway="" />
    <nic id="3" name="BlockStorage" static="true" ip="10.10.9.8" subnet="255.255.255.0" gateway="" />
    <nic id="4" name="FileStorage" static="false" ip="10.10.10.8" subnet="255.255.255.0" gateway="" />
  </networkadapters>   
</config>