A virtual switch, like its physical counterpart, is a device that functions at Layer 2 of the Open Systems Interconnect (OSI) reference model. A switch has a series of ports, each of which is connected to a computer’s network interface adapter. Any computer connected to the switch can transmit data to any other computer connected to the same switch.
Unlike physical switches, the virtual switches created by Hyper-V can have an unlimited number of ports, so administrators don’t have to be concerned about connecting switches together or about uplinks and crossover circuits.
Creating the default virtual switch
The Windows Server 2012 R2 Add Roles and Features Wizard provides the opportunity to create virtual switches when you install the Hyper-V role. When you install Hyper-V on a server running Windows Server 2012 R2, the Create Virtual Switches page provides you with the opportunity to create a virtual switch for each of the physical network adapters installed in the host computer. These switches enable VMs to participate on the networks to which the physical adapters are connected.
When you create a virtual switch, the networking configuration in the host OS on the parent partition changes. The new virtual switch appears in the Network Connections window, and if you examine its properties, you can see that the switch is bound to the operating system’s TCP/IP client, as shown in Figure 3-26.
Meanwhile, Hyper-V also changes the properties of original network connection representing the physical network interface adapter in the computer. The physical network adapter is now bound only to the virtual switch, as shown in Figure 3-27.
As a result, the computer’s physical network configuration, in which its network adapter is connected to an external physical switch, is overlaid by the virtual network configuration created by Hyper-V. In this virtual configuration, the virtual switch is connected to the physical switch and the network adapter in the host OS is connected to the virtual switch. The internal virtual network and the external physical network are joined into a single LAN, just as if you connected two physical switches.
FIGURE 3-26 A virtual switch and its properties, displayed in the host OS
FIGURE 3-27 A network interface adapter in the host OS, bound to a virtual switch
Once Hyper-V has created the virtual switch and made these configuration changes, any new VMs that administrators choose to connect to the virtual switch become part of this conjoined network, as do any physical computers connected to the physical network through an external switch.
This type of virtual switch is, in Hyper-V terminology, an external network switch because it provides connections external to the Hyper-V environment. This is typically the preferred arrangement for a production network in which Hyper-V VMs provide and consume services for the entire network.
For example, a VM connected to this switch will automatically obtain an IP address from a Dynamic Host Configuration Protocol (DHCP) server on the physical network, if there is one.
As an alternative, you could configure a VM as a DHCP server and let it provide addresses to all of the systems on the network, virtual or physical.
Perhaps more important, this arrangement can also enable your VMs to access the Internet by using the router and DNS servers on the external network. The VMs can then download OS updates from servers on the Internet, just as external machines often do.
There are situations in which this type of virtual switch is inappropriate. If you are creating a laboratory network for product testing or a classroom network, you might not want it to be accessible to or from the external network. In these cases, you must create a different type of virtual switch by using the Virtual Switch Manager in Hyper-V Manager.
Creating a new virtual switch
Hyper-V in Windows Server 2012 R2 supports three types of switches, which you must create in the Virtual Switch Manager before you can connect VMs to them.
To create a new virtual switch, use the following procedure.
1. In Server Manager, on the Tools menu, select Hyper-V Manager to open the Hyper-V Manager console.
2. In the left pane, select a Hyper-V server.
3. From the Actions pane, select Virtual Switch Manager. The Virtual Switch Manager dialog box for the Hyper-V server opens, as shown in Figure 3-28.
FIGURE 3-28 The Virtual Switch Manager dialog box
4. In the Create Virtual Switch section, select one of the following switch types:
– External The virtual switch is bound to the networking protocol stack in the host OS and connected to a physical network interface adapter in the Hyper-V server.
VMs running on the server’s parent and child partitions can all access the physical network to which the physical adapter is connected.
– Internal An internal network switch is bound to a separate instance of the networking protocol stack in the host OS, independent from the physical network interface adapter and its connected network. VMs running on the server’s parent and child partitions can all access the virtual network implemented by the virtual
switch; the host OS on the parent partition can access the physical network through the physical network interface adapter, but the VMs on the child partitions cannot access the physical network through the physical adapter.
– Private A private network switch exists only in the Hyper-V server and is accessible only to the VMs running on the child partitions. The host OS on the parent partition can access the physical network through the physical network interface adapter, but it cannot access the virtual network created by the virtual switch.
5. Click Create Virtual Switch to open the Virtual Switch Properties page.
6. Configure the following options, if desired:
– Allow Management Operating System To Share This Network Adapter Selected by default when you create an external virtual switch, clearing this check box excludes the host OS from the physical network while allowing access to the child VMs.
– Enable Single Root I/O Virtualization (SR-IOV) Enables you to create an external virtual switch that is associated with a physical network adapter capable of supporting SR-IOV. This option is only available when creating a new virtual switch; you cannot modify an existing virtual switch to use this option.
– Enable Virtual LAN Identification For Management Operating System If your host computer is connected to a physical switching infrastructure that uses virtual LANs (VLANs) to create separate subnets, you can select this check box and enter a VLAN identifier to associate the virtual switch with a particular VLAN on your physical network.
7. Click OK. The new virtual switch appears in the left pane, in the list of virtual switches.
You can create additional virtual switches as needed. You can create only one external switch for each physical network adapter in the computer, but you can create multiple internal or private switches to create as many virtual networks as you need.
NOTE: USING WINDOWS POWERSHELL
To create a new virtual switch by using Windows PowerShell, use the New-VMSwitch
cmdlet with the following basic syntax:
New-VMSwitch <switch name> -NetAdapterName <adapter name>
For example, to create an external switch called LAN Switch, you would use the following
New-VMSwitch “LAN Switch” –NetAdapterName “Ethernet”
Configuring MAC addresses
Every network interface adapter has a Media Access Control (MAC) address—sometimes called a hardware address—that uniquely identifies the device on the network. On physical network adapters, the MAC is assigned by the manufacturer and permanently entered in the adapter’s firmware. The MAC address is a 6-byte hexadecimal value, the first three bytes of which are an organizationally unique identifier (OUI) that specifies the manufacturer, and the last three bytes of which identify the adapter itself.
The MAC address is essential to the operation of a LAN, so the virtual network adapters on a Hyper-V server need to have them. The server has at least one real MAC address, provided in its physical network adapter, but Hyper-V cannot use that one address for all the virtual adapters connecting VMs to the network.
Instead, Hyper-V creates a pool of MAC addresses during the installation of the role and it assigns addresses from this pool to VMs as you create them. To view or modify the MAC address pool for the Hyper-V server, you open the Virtual Switch Manager and, under Global Network Settings, select MAC Address Range, as shown in Figure 3-29.
FIGURE 3-29 The MAC Address Range in the Virtual Switch Manager
The first three bytes of the MAC address range are always 00-15-5D, which is an OUI registered by Microsoft. The fourth and fifth bytes of the MAC address are the last two bytes of the IP address assigned to the server’s physical network adapter, converted to hexadecimal notation. The sixth and last byte of the MAC address contains the range of values from 00 to FF, which provides 256 possible addresses.
The Hyper-V server assigns the MAC addresses to the network adapters in VMs as administrators create the adapters. The adapters retain their MAC addresses permanently or until the adapter is removed from the VM. The server reclaims any unused addresses and reuses them. The default pool of 256 addresses is expected to be sufficient for most Hyper-V VM configurations, but if it is not, you can modify the Minimum and Maximum values to enlarge the pool. To prevent address duplication, you should change the second-to-last byte only,
making it into a range of addresses like the last byte.
For example, the range illustrated in the figure provides 256 addresses with the following values:
00-15-1D-02-12-00 to 00-15-1D-02-12-FF
Modifying only the least significant digit, as in the following values, increases the pool from 256 to 4,096:
00-15-1D-02-10-00 to 00-15-1D-02-1F-FF
WARNING MAC ADDRESSES
When you modify the MAC address pool and you have other Hyper-V servers on your network, you must be careful not to create an overlap situation in which duplicate MAC addresses can occur or networking problems can result.
This article is a part of 70-410 Installing and Configuring Windows Server 2012 Prep course, more articles in this course are :
70-410 Installing and Configuring Windows Server 2012 Prep course includes following practice tests: