Running Hyper-V Server 2012 R2: Setting your NIC cards up for iSCSI under Windows Core

You will note that if you ever have to work on a Windows 2012 Core machine (for example, Microsoft’s free Hyper-V server), that all of the sudden you have to use a lot more PowerShell commands. Core installs don’t just remove a lot of the GUI cruft, but also much of the GUI you might not expect to see going away. Fortunately such necessities as the iSCSI configuration control panel (invoked from the command line using “iscsicpl.exe”) are still alive and kicking, but basic NIC configuration and even access to the device manager (even remotely) are now gone, which can be tough even for command-line oriented admins who are used to having this stuff around. This can be pain when properly configuring an iSCSI-facing NIC in your lab (unless you can afford an actual HBA), which ideally shouldn’t have much other than pure IPv4 running on it, and should preferably be using jumbo frames.

Names

Fortunately, once you know the commands, a lot of this becomes pretty easy. The first thing we need to do is give our NICs some meaningful names so we don’t accidentally do something stupid. Not that this will be 100% proof against doing anything stupid, but it’s a nice start.

To do this, we’re just going to use the Get-NetAdapter cmdlet to find out what the current names are, then then assign a new name with Rename-NetAdapter. (I only changed the iSCSI adapter in this example, but you should probably give all the physical NICs names that aren’t useless.)

PS C:\Users\Joe> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Ethernet 3                Intel(R) Gigabit CT Desktop Adapter          14 Up           68-05-CA-25-D5-4A         1 Gbps
vEthernet (Default Net... Hyper-V Virtual Ethernet Adapter #2          21 Up           D0-50-99-47-A0-B5        10 Gbps
Ethernet 2                Qualcomm Atheros AR8171/8175 PCI-E G...      13 Up           D0-50-99-47-A0-B5         1 Gbps


PS C:\Users\Joe> Rename-NetAdapter -Name "Ethernet 3" -NewName "iSCSI"
PS C:\Users\Joe> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
iSCSI                     Intel(R) Gigabit CT Desktop Adapter          14 Up           68-05-CA-25-D5-4A         1 Gbps
vEthernet (Default Net... Hyper-V Virtual Ethernet Adapter #2          21 Up           D0-50-99-47-A0-B5        10 Gbps
Ethernet 2                Qualcomm Atheros AR8171/8175 PCI-E G...      13 Up           D0-50-99-47-A0-B5         1 Gbps

 

Bindings

Well now that we’ve done that, we need to discover what bindings our iSCSI adapter is using, and turn off everything we don’t need. The cmdlets here are Get-NetAdapterBinding and Disable-NetAdapterBinding. (However, you may want to use Enable-NetAdapterBinding if you turn off the wrong thing!) We’re going to turn off EVERYTHING that isn’t TCP/IPv4 (aka ms_tcpip).  Don’t forget the 6 at the end of ms_tcpip6 or you’ll turn off the wrong binding!

PS C:\Users\Joe> Get-NetAdapterBinding -Name "iSCSI"

Name                           DisplayName                                        ComponentID          Enabled
----                           -----------                                        -----------          -------
iSCSI                          Link-Layer Topology Discovery Responder            ms_rspndr            True
iSCSI                          Link-Layer Topology Discovery Mapper I/O Driver    ms_lltdio            True
iSCSI                          Microsoft Network Adapter Multiplexor Protocol     ms_implat            False
iSCSI                          Hyper-V Extensible Virtual Switch                  vms_pp               False
iSCSI                          Client for Microsoft Networks                      ms_msclient          True
iSCSI                          Microsoft Failover Cluster Virtual Adapter Perf... ms_netftflt          False
iSCSI                          QoS Packet Scheduler                               ms_pacer             True
iSCSI                          File and Printer Sharing for Microsoft Networks    ms_server            True
iSCSI                          Internet Protocol Version 6 (TCP/IPv6)             ms_tcpip6            True
iSCSI                          Internet Protocol Version 4 (TCP/IPv4)             ms_tcpip             True


PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_rspndr
PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_lltdio
PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_msclient
PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_pacer
PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_server
PS C:\Users\Joe> Disable-NetAdapterBinding -Name "iSCSI" -ComponentID ms_tcpip6
PS C:\Users\Joe> Get-NetAdapterBinding -Name "iSCSI"

Name                           DisplayName                                        ComponentID          Enabled
----                           -----------                                        -----------          -------
iSCSI                          Link-Layer Topology Discovery Responder            ms_rspndr            False
iSCSI                          Link-Layer Topology Discovery Mapper I/O Driver    ms_lltdio            False
iSCSI                          Microsoft Network Adapter Multiplexor Protocol     ms_implat            False
iSCSI                          Hyper-V Extensible Virtual Switch                  vms_pp               False
iSCSI                          Client for Microsoft Networks                      ms_msclient          False
iSCSI                          Microsoft Failover Cluster Virtual Adapter Perf... ms_netftflt          False
iSCSI                          QoS Packet Scheduler                               ms_pacer             False
iSCSI                          File and Printer Sharing for Microsoft Networks    ms_server            False
iSCSI                          Internet Protocol Version 6 (TCP/IPv6)             ms_tcpip6            False
iSCSI                          Internet Protocol Version 4 (TCP/IPv4)             ms_tcpip             True

 

Jumbo Frames

Next, we want to use Jumbo Frames wherever possible on an iSCSI connection. Of course, we all made sure that Jumbo Frames were supported and enabled on the switch and NAS/SAN before getting here, right? Jumbo Frames are generally defined as being packets with at least an MTU (maximum transmission unit, or packet payload size) of 9000 bytes (or a total size of 9014 bytes) that will gives us faster speeds on our LAN, but risk being chopped ups if they hop over routers with smaller MTU links in between. Since iSCSI is ideally on a secluded, nicely-designed, and unrouted network, or at least one with very well designed secluded, minimal-hop network, the latter should not be a problem. Some equipment supports even larger Jumbo Frame MTUs, but make sure you check your documentation on all involved equipment before you do that (NAS/SAN, switch, and all connected NICs). We configure Jumbo Frames at the driver level, which makes the absence of Device Manager a more notable pain than usual, but fortunately not a severe one. Here we will use the Get-NetAdapterAdvancedProperty and Set-NetAdapterAdvancedProperty cmdlets. There are two potential gotchas here: you will note that the registry value for *JumboPacket is the whole frame size, not just the payload, (1514 and 9014 bytes), and that *JumboPacket does, in fact, have an asterisk in front of it. Make sure you take those things into account.

PS C:\Users\Joe> Get-NetAdapterAdvancedProperty -Name "iSCSI"

Name                      DisplayName                    DisplayValue                   RegistryKeyword RegistryValue
----                      -----------                    ------------                   --------------- -------------
iSCSI                     Flow Control                   Rx & Tx Enabled                *FlowControl    {3}
iSCSI                     Interrupt Moderation           Enabled                        *InterruptMo... {1}
iSCSI                     IPv4 Checksum Offload          Rx & Tx Enabled                *IPChecksumO... {3}
iSCSI                     Jumbo Packet                   Disabled                       *JumboPacket    {1514}
iSCSI                     Large Send Offload V2 (IPv4)   Enabled                        *LsoV2IPv4      {1}
iSCSI                     Large Send Offload V2 (IPv6)   Enabled                        *LsoV2IPv6      {1}
iSCSI                     Maximum number of RSS Proce... 8                              *MaxRssProce... {8}
iSCSI                     Preferred NUMA node            System Default                 *NumaNodeId     {65535}
iSCSI                     Maximum Number of RSS Queues   2 Queues                       *NumRssQueues   {2}
iSCSI                     Packet Priority & VLAN         Packet Priority & VLAN Enabled *PriorityVLA... {3}
iSCSI                     Receive Buffers                256                            *ReceiveBuffers {256}
iSCSI                     Receive Side Scaling           Enabled                        *RSS            {1}
iSCSI                     RSS Base Processor Number      0                              *RssBaseProc... {0}
iSCSI                     Maximum RSS Processor Number   63                             *RssMaxProcN... {63}
iSCSI                     RSS load balancing profile     NUMAScalingStatic              *RSSProfile     {4}
iSCSI                     Speed & Duplex                 Auto Negotiation               *SpeedDuplex    {0}
iSCSI                     TCP Checksum Offload (IPv4)    Rx & Tx Enabled                *TCPChecksum... {3}
iSCSI                     TCP Checksum Offload (IPv6)    Rx & Tx Enabled                *TCPChecksum... {3}
iSCSI                     Transmit Buffers               512                            *TransmitBuf... {512}
iSCSI                     UDP Checksum Offload (IPv4)    Rx & Tx Enabled                *UDPChecksum... {3}
iSCSI                     UDP Checksum Offload (IPv6)    Rx & Tx Enabled                *UDPChecksum... {3}
iSCSI                     Adaptive Inter-Frame Spacing   Disabled                       AdaptiveIFS     {0}
iSCSI                     Interrupt Moderation Rate      Adaptive                       ITR             {65535}
iSCSI                     Log Link State Event           Enabled                        LogLinkState... {51}
iSCSI                     Gigabit Master Slave Mode      Auto Detect                    MasterSlave     {0}
iSCSI                     Locally Administered Address   --                             NetworkAddress  {--}
iSCSI                     Wait for Link                  Auto Detect                    WaitAutoNegC... {2}


PS C:\Users\Joe> Set-NetAdapterAdvancedProperty -Name "iSCSI" -RegistryKeyword "*JumboPacket" -RegistryValue 9014
PS C:\Users\Joe> Get-NetAdapterAdvancedProperty -Name "iSCSI"

Name                      DisplayName                    DisplayValue                   RegistryKeyword RegistryValue
----                      -----------                    ------------                   --------------- -------------
iSCSI                     Flow Control                   Rx & Tx Enabled                *FlowControl    {3}
iSCSI                     Interrupt Moderation           Enabled                        *InterruptMo... {1}
iSCSI                     IPv4 Checksum Offload          Rx & Tx Enabled                *IPChecksumO... {3}
iSCSI                     Jumbo Packet                   9014 Bytes                     *JumboPacket    {9014}
iSCSI                     Large Send Offload V2 (IPv4)   Enabled                        *LsoV2IPv4      {1}
iSCSI                     Large Send Offload V2 (IPv6)   Enabled                        *LsoV2IPv6      {1}
iSCSI                     Maximum number of RSS Proce... 8                              *MaxRssProce... {8}
iSCSI                     Preferred NUMA node            System Default                 *NumaNodeId     {65535}
iSCSI                     Maximum Number of RSS Queues   2 Queues                       *NumRssQueues   {2}
iSCSI                     Packet Priority & VLAN         Packet Priority & VLAN Enabled *PriorityVLA... {3}
iSCSI                     Receive Buffers                256                            *ReceiveBuffers {256}
iSCSI                     Receive Side Scaling           Enabled                        *RSS            {1}
iSCSI                     RSS Base Processor Number      0                              *RssBaseProc... {0}
iSCSI                     Maximum RSS Processor Number   63                             *RssMaxProcN... {63}
iSCSI                     RSS load balancing profile     NUMAScalingStatic              *RSSProfile     {4}
iSCSI                     Speed & Duplex                 Auto Negotiation               *SpeedDuplex    {0}
iSCSI                     TCP Checksum Offload (IPv4)    Rx & Tx Enabled                *TCPChecksum... {3}
iSCSI                     TCP Checksum Offload (IPv6)    Rx & Tx Enabled                *TCPChecksum... {3}
iSCSI                     Transmit Buffers               512                            *TransmitBuf... {512}
iSCSI                     UDP Checksum Offload (IPv4)    Rx & Tx Enabled                *UDPChecksum... {3}
iSCSI                     UDP Checksum Offload (IPv6)    Rx & Tx Enabled                *UDPChecksum... {3}
iSCSI                     Adaptive Inter-Frame Spacing   Disabled                       AdaptiveIFS     {0}
iSCSI                     Interrupt Moderation Rate      Adaptive                       ITR             {65535}
iSCSI                     Log Link State Event           Enabled                        LogLinkState... {51}
iSCSI                     Gigabit Master Slave Mode      Auto Detect                    MasterSlave     {0}
iSCSI                     Locally Administered Address   --                             NetworkAddress  {--}
iSCSI                     Wait for Link                  Auto Detect                    WaitAutoNegC... {2}

 

DNS

We won’t be needing this connection to register with any DNS servers, and really we don’t want it, so let’s nip that in the bud right now. We can just use Set-DnsClient to do this and check our work with Get-DnsClient.

PS C:\Users\Joe> Set-DnsClient -RegisterThisConnectionsAddress $false -InterfaceAlias "iSCSI"
PS C:\Users\Joe> Get-DnsClient

InterfaceAlias               Interface ConnectionSpecificSuffix ConnectionSpecificSuffix RegisterThisConn UseSuffixWhen
                             Index                              SearchList               ectionsAddress   Registering
--------------               --------- ------------------------ ------------------------ ---------------- -------------
vEthernet (Default Network)         21                          {}                       True             False
isatap.{38259F1E-3930-48A...        15                          {}                       False            False
iSCSI                               14                          {}                       False            False
isatap.{A9CBDBFF-EF05-44D...        17                          {}                       False            False
Local Area Connection* 11           18                          {}                       True             False
isatap.{4923699D-4C1D-487...        19                          {}                       False            False
Loopback Pseudo-Interface 1          1                          {}                       False            False

 

NetBIOS

And the last thing we need to remove is probably the hardest, because it’s not something we can do directly via PowerShell.  However, despite the pain we really want to remove NetBIOS because it is a horrible protocol and if it gets accidentally triggered, it’ll slow down our iSCSI network with horrible broadcast chattiness. We have to invoke the WMI Command Line tool (wmic), and our PowerShell names and index numbers for any NICs we choose to configure will not be valid there. The first command I use is just to find the index number for my interface so I can set it using my second command. It’s also important to note that PowerShell will also mess up the command formatting if we’re not careful and maybe even botch some of the replies. You will note I have put double quotes around all my commas to pass them to wmic and not have them eaten by PowerShell, and you’ll also note that even though I was able to make my change, PowerShell threw back a huge, scary error.  This is not because the command failed, but PowerShell was expecting a response from the command and it didn’t give one.

PS C:\Users\Joe> wmic nicconfig get caption","index","TcpipNetbiosOptions
Caption                                                                                Index  TcpipNetbiosOptions

[00000000] WAN Miniport (L2TP)                                                         0

[00000001] WAN Miniport (SSTP)                                                         1

[00000002] WAN Miniport (IKEv2)                                                        2

[00000003] WAN Miniport (PPTP)                                                         3

[00000004] WAN Miniport (PPPOE)                                                        4

[00000005] WAN Miniport (IP)                                                           5

[00000006] WAN Miniport (IPv6)                                                         6

[00000007] WAN Miniport (Network Monitor)                                              7

[00000008] Hyper-V Virtual Ethernet Adapter                                            8

[00000009] Microsoft Kernel Debug Network Adapter                                      9

[00000010] RAS Async Adapter                                                           10

[00000011] Qualcomm Atheros AR8171/8175 PCI-E Gigabit Ethernet Controller (NDIS 6.30)  11

[00000012] Intel(R) Gigabit CT Desktop Adapter                                         12     0

[00000013] Microsoft ISATAP Adapter                                                    13

[00000014] Microsoft Teredo Tunneling Adapter                                          14

[00000015] Microsoft ISATAP Adapter                                                    15

[00000016] Microsoft Failover Cluster Virtual Adapter                                  16     0

[00000017] Microsoft ISATAP Adapter                                                    17

[00000018] Hyper-V Virtual Switch Extension Adapter                                    18

[00000019] Hyper-V Virtual Ethernet Adapter                                            19     0


PS C:\Users\Joe> wmic nicconfig where index=12 call SetTcpipNetbios 2
Executing (\\VHOST0\ROOT\CIMV2:Win32_NetworkAdapterConfiguration.Index=12)->SetTcpipNetbios()

Method execution successful.

Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};
wmic :
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

PS C:\Users\Joe> wmic nicconfig get caption","index","TcpipNetbiosOptions
Caption                                                                                Index  TcpipNetbiosOptions

[00000000] WAN Miniport (L2TP)                                                         0

[00000001] WAN Miniport (SSTP)                                                         1

[00000002] WAN Miniport (IKEv2)                                                        2

[00000003] WAN Miniport (PPTP)                                                         3

[00000004] WAN Miniport (PPPOE)                                                        4

[00000005] WAN Miniport (IP)                                                           5

[00000006] WAN Miniport (IPv6)                                                         6

[00000007] WAN Miniport (Network Monitor)                                              7

[00000008] Hyper-V Virtual Ethernet Adapter                                            8

[00000009] Microsoft Kernel Debug Network Adapter                                      9

[00000010] RAS Async Adapter                                                           10

[00000011] Qualcomm Atheros AR8171/8175 PCI-E Gigabit Ethernet Controller (NDIS 6.30)  11

[00000012] Intel(R) Gigabit CT Desktop Adapter                                         12     2

[00000013] Microsoft ISATAP Adapter                                                    13

[00000014] Microsoft Teredo Tunneling Adapter                                          14

[00000015] Microsoft ISATAP Adapter                                                    15

[00000016] Microsoft Failover Cluster Virtual Adapter                                  16     0

[00000017] Microsoft ISATAP Adapter                                                    17

[00000018] Hyper-V Virtual Switch Extension Adapter                                    18

[00000019] Hyper-V Virtual Ethernet Adapter                                            19     0

 

Success

If all has gone well, you should be up and running.  Obviously this is all easily scriptable for a mass deployment, but do it manually your first time to get a good sense of what will need to be done. Ping your NAS or SAN to make sure you haven’t broken anything and then you can fire up iscsicpl.exe to set up the iSCSI configuration! If you need any more help or want to try to do some things a bit beyond what you see here, you can try these sources that I used to get this all working: