User Tools

Site Tools


virtualization:microsoft:hyper-v-nic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
virtualization:microsoft:hyper-v-nic [2013/08/07 15:08]
gcooper created
virtualization:microsoft:hyper-v-nic [2014/07/08 12:04] (current)
gcooper
Line 1: Line 1:
-====== Configuring Hyper-V Network Interfaces ======+====== 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/ 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 =====
 +
 +<file>
 +netsh interface set interface "Local Area Connection 2" newname="Management"
 +</file>
  
 ===== Get-NICInformation.ps1 ===== ===== Get-NICInformation.ps1 =====
Line 26: Line 73:
 #endregion #endregion
    
-$adapters = Get-WMIObject Win32_PNPSignedDriver | Where-Object { $_.DeviceClass -eq NET” -and $_.HardWareID -like *PCI*” } | Sort-Object location+$adapters = Get-WMIObject Win32_PNPSignedDriver | Where-Object { $_.DeviceClass -eq "NET-and $_.HardWareID -like "*PCI*} | Sort-Object location
      
 foreach ($adapter in $adapters ) { foreach ($adapter in $adapters ) {
Line 46: Line 93:
      
 } }
 +</file>
 +
 +===== Set-IPAddressFromXML.ps1 =====
 +
 +<file>
 +# ---------------------------------------------------------------------------------------------- #
 +# 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
 +</file>
 +
 +===== networkconfig.xml =====
 +
 +<file>
 +<?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>
 </file> </file>
virtualization/microsoft/hyper-v-nic.1375909706.txt.gz · Last modified: 2013/08/07 15:08 by gcooper