Network Device Naming in Windows Server 2016 Hyper-V

Posted on May 5, 2017 by Aidan Finn in Backup & Storage, Hyper-V, Virtualization, Windows Server 2016 with

With Microsoft a No-Show at Mobile World Congress, Partners Step Up

In this post, I will show you why and how to use a new feature in Windows Server 2016 (WS2016) that is called Network Device Naming. You can name your virtual NICs in the settings of the virtual machine and retrieve or use that name in the guest OS.

 

 

The Need for Device Naming

Most of the time, a virtual machine will have a single virtual NIC that is connected to a virtual switch or network. In turn, it is connected to a team of physical NICs in the host. On rare occasions, you need to add more than one NIC to a virtual machine:

  • Guest clusters: An application will be made highly available in 2 or more virtual machines. You will want to use more virtual NICs to make up additional clustering or storage networks.
  • Virtual network appliances (NVAs): The role of a firewall, router, or similar networking device can be played by a virtual machine that is running a special OS and/or software. This is common in cloud and private cloud computing. These devices might have multiple ports, where each is a virtual NIC. They are connected to different networks.
  • Storage networking: Some virtual storage appliances (VSAs), such as the Microsoft Azure StorSimple 1200, can enable iSCSI. This should be partitioned out to separate virtual NICs.

Adding NICs to Hyper-V virtual machines is easy. It is even easier with hot-add support in WS2016 but this can create some problems. Let’s say you build a virtual machine with 3 virtual NICs. You install or attach a guest OS to that virtual machine. What will the NICs be called in the guest OS? One might think, “NIC1 will be Ethernet1. NIC2 will be Ethernet2.” That thinking would be wrong. As always, Windows approaches plug and play in a random manner. There is no reliable link between the ordering of the NICs in the virtual machine configuration and the naming of the NICs in the guest OS.

Sponsored

The old way that we identified the virtual machine NIC was connected to the interface in the guest OS:

  1. Create the NICs without connecting them to a network.
  2. Get the guest OS running.
  3. Connect NIC1. Identify and rename it in the guest OS.
  4. Repeat step 3 for each additional NIC.

Unfortunately, this method is slow, not automatable for large deployments, and assumes that the guest OS admin will have sufficient rights to edit the virtual machine settings.

Consistent Device Naming

Microsoft already gave us a way to associate interface names with their PCI slot location in Windows Server 2012 (WS2012). Do we need anything else? Consistent device naming (CDN) was added in WS2012. It only works on some physical servers, where device naming is enabled. CDN does nothing for the aforementioned virtual machine scenarios because CDN works at the physical layer.

Network Device Naming

Hopefully, you read my networking chapter in a past book on WS2012 Hyper-V. We do not have to use the meaningless default of Network Adapter. The chapter discusses how PowerShell made it possible to create a NIC in a virtual machine with a user-friendly name. We can do that on WS2016 using the following cmdlet:

We can go one step further on WS2016 by passing the name of the NIC into the guest OS. It can be retrieved from there. You can make this possible by adding an extra parameter to the above command:

When you log into the virtual machine, you will find that the Storage 1 NIC is still using one of the meaningless Ethernet names. We can find the Ethernet NIC named Storage 1 and rename it.

If you want to do it manually, open up the properties of the NIC in Control Panel in the guest OS. Click the Configure button, browse to the Advanced tab, and look for a setting called Hyper-V Network Adapter Name.

Sponsored

If you want to use PowerShell, then you can run the following:

Sponsored

Tagged with , , , , ,

Register for this Webinar