====== Configuring Hyper-V Network Interfaces for Clustering ====== See also **[[networking:windows:network_profiles|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//: - Parent (Management) - VM (for the Virtual Network, prior to the Virtual Switch) - Cluster Communications/CSV - Live Migration As the number of NICs proliferate: - The number/cost of NICs go up - The number/cost of switch ports goes up - The wasted rack space cost goes up - The power bill goes up - The support cost for your network goes up - The complexity goes up ===== Basic Steps for Identical Hardware ===== - Rename the NICs of the first host - Run the ''Get-NICInformation.ps1'' on the first host and check the NIC order - Edit the ''networkconfig.xml'' on the second hosts with the right order of the NICs - Run the ''Set-IPAddressfromXML.ps1'' - Do this for all Hyper-V Hosts ===== Possible Hyper-V NIC Names ===== With four NICs: * Management * GuestPublic * BlockStorage * FileStorage ===== 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 =====