What's new

Hyper-V Virtual Switch Manager

Hyper-V Virtual Switch 101: How to create and use Virtual Switches to connect Virtual Machines to Network

information   Information
I will try to make this tutorial as simple and easy to understand as possible. Therefore some examples used might seem to you fellow geeks too simple. However, I ask you to understand that my goal is to make this so easy every noob can start "switching" :p.

Please response by providing your own tips, tricks, links and telling about your experiences.

For beginners I recommend to start with Dwarf’s excellent and easy to understand tutorial Hyper-V - How to Use in Windows 8.




Part 1: Understanding Virtual Switches

To connect a virtual machine (hereafter vm) to network it needs a network controller (hereafter NIC) the same way as any physical computer would need. In Hyper-V virtualization this NIC is of course virtual, it does not exists physically.

As we cannot connect a virtual NIC to a physical router we need a Virtual Switch (hereafter VS) to act like a network bridge between host NIC and vm virtual NIC. See the image below:
Virtual_Switch_12.png

A Virtual Switch can be external, internal or private.
  • External Virtual Switch: will connect a vm to host NIC. If host NIC is connected to Internet through router, the vm is also connected to Internet. If host NIC (LAN) is not connected to router or if the router has no Internet access, the internal network will still work allowing computers (physical and vm) belonging to the same subnet and workgroup or domain to communicate with each other (file and media sharing etc.). When connecting external switch to host WLAN NIC, the vm loses all connectivity when WLAN is disabled or not connected on host.
  • Internal Virtual Switch: When a virtual NIC is connected to Internal VS it can communicate with other computers and vms on the same subnet but has no Internet access if host Ethernet or WLAN connection is not shared with it.
  • Private Virtual Switch: When a virtual NIC is connected to Private VS it can communicate with other vms on same Hyper-V server but cannot communicate with host PC nor has it Internet access. A Private vs is often needed when installing a legacy Linux or pre-XP Windows vm. After installation you need then to disable Private Switch and use Internal or External to connect to the network.

Part 2. Create a Virtual Switch


  1. To create a VS open Hyper-V Virtual Switch Manager:
    .
    Virtual_Switch_10.png
    .
  2. Select New virtual network switch, select the switch type and click Create Virtual Switch:
    .
    Virtual_Switch_11.png
    .
  3. Name the switch as you wish, select which of host NICs it will be connected to. Please check that the option Allow management operating system to share this network adapter is selected, otherwise you might lose all connectivity:
    .
    Virtual_Switch_05.png
    .
- What this means, to put it very simple, is that when sharing is not enabled the virtual machines using a non-shared external switch can communicate with each other and outside world, but they will not share the connection with host. In this case you need to use another NIC and connection to connect host to the Internet​
.​
- Notice that this is also a practical way to use two totally different Internet connections with two independent routers and subscriber lines thus getting two different public IPs. An external virtual switch in this case takes total control of NIC it is connected to leaving host without connection if it can not use another NIC​
.​
- Also important to notice that to get two separate public IPs the external switch must not be shared, and host needs to be connected not only with another NIC but with another router and subscriber line. If both NICS belong to the same subnet and are using the same router / line they always share the public IP​
.​
4. Before clicking OK to save new switch you just created check that you have no active network connections used to anything important at the moment, for instance unfinished downloads or backups to a network location; when you click Apply or OK the network connection of your host is disconnected shortly before a new connection is created.​

By default all virtual switches get the name vEthernet followed by the name you selected when you created it within parenthesis. Here's how system named for instance my external switch connected to LAN NIC on my host: vEthernet (AGMnet External LAN).

Screenshot below shows typical available network connections when all types of virtual switches have been created:
Virtual_Switch_15.png
(Physical host NICS highlighted with yellow, virtual switches with red.)​

Notice that external virtual switch connected to host WLAN (vEthernet (AGMnet External WLAN) in this example) is not connected, showing red X. This is because of the WLAN NIC of host is disconnected (greyed out in screenshot); a virtual machine using this virtual switch would have no connectivity at the moment.

You might have also noticed that although the virtual switch vEthernet (AGMnet External WLAN) is connected to (is using) host’s WLAN NIC it is however showing an Ethernet LAN symbol (connector of a LAN cable) and presented under LAN connections. This has a simple explanation: all Hyper-V network connections are Ethernet (LAN) connections; Hyper-V does not support WiFi so even when a virtual switch is connected to a wireless NIC, Hyper-V presents it as Ethernet connection to the virtual machine i.e. the virtual NIC on vm “thinks” it is connected with an Ethernet cable.

This also means that when we are using an external virtual switch connected to a WLAN NIC, we need an extra network bridge on the host. The virtual NIC connects to a virtual switch, virtual switch in its turn connects to a host network bridge which creates (as its name says) a bridge between our virtual Ethernet connection and host WLAN NIC’s connection to the router:
Virtual_Switch_16.png

A "real life" situation from my computer. Virtual machine sees the connection as an Ethernet connection, connecting its Virtual NIC to External Virtual Switch, which in its turn is connected to a Network Bridge on host and further to WLAN NIC on host. Sounds complicated, is simple:
Virtual_Switch_04.png
Don’t worry be happy, Hyper-V and your Windows 8 host are together taking care of creating bridges when needed. See the screenshot below, I have just enabled and connected my host’s WiFi NIC. When enabled it noticed that there’s a Hyper-V external virtual switch which wants to use it so it created a Network Bridge, which then told external virtual WLAN switch “it’s OK now, we are online” ;).

Red X disappeared, a vm using this connection would be back in business:
Virtual_Switch_17.png


Part 3: Connect a Virtual Machine to a Virtual Switch (vm with Windows Vista SP2 or later Windows OS )

When creating a new vm select the correct virtual switch for your purposes. To connect vm to other computers and to Internet select an external switch which is connected to a host NIC currently enabled, connected, and online:
Virtual_Switch_13.png

You can always change the virtual switch from vm Settings:
Virtual_Switch_14.png

You are now ready to start networking!

Part 4: Connect a Virtual Machine to a Virtual Switch (vm with pre Windows Vista SP2 or Linux / Unix OS )

As you already know the expression “Not supported” does not always mean it wont work. Several Linux distros as well as early versions of Windows run very nicely on Hyper-V although officially it only supports XP and later Windows versions. Read for instance this tutorial to see how you can install Open SUSE or Ubuntu Linux on a Hyper-V vm: Hyper-V – Create Linux Virtual Machine in Windows 8.

When creating a new vm for Linux or older Windows versions it is important to follow these steps in setting up network functionality:
  1. Select Not connected when creating vm:
    .
    Virtual_Switch_06.png
    .
  2. Before booting vm first time go to Settings and delete (remove) default network driver:
    .
    Virtual_Switch_07.png
    .
  3. Create a new virtual Legacy Network Adapter:
    .
    Virtual_Switch_08.png
    .
  4. Create a Private Virtual Switch, attach it to newly created Legacy Network Adapter:
    .
    Virtual_Switch_09.png
    .
  5. Boot and install OS
  6. When on desktop, shut down vm before starting any other apps or programs or changing vm settings
  7. When vm is shut down, go to virtual machine's Settings and connect the Legacy Network Adapter to an External Virtual Switch with network connectivity
  8. Boot the vm and you are ready to go online!


A few more words

After you have created an external virtual switch, your Windows host computer starts using it, too. No reason to change this, as long as your external virtual switch is online everything will be OK:
Virtual_Switch_01.png

Remember, Hyper-V and windows are taking care of the bridges when needed. Host Network Bridge does exist only when host WLAN is enabled, and is appearing offline when WLAN is not connected:
Virtual_Switch_02.png

If a vm cannot connect to network, check first that it is using a correct external virtual switch and that the said switch is connected to a NIC which is enabled and connected:
Virtual_Switch_03.png

That's it. Please do tell if you find errors. All input is wanted and appreciated.


Kari


 

Attachments

  • LAN.png
    LAN.png
    6.4 KB · Views: 253
Last edited by a moderator:

rowlands111

Member
Member
Great guide. I've encountered an error where if I disable Hyper-V by "Turn Windows Features on or off," and then proceed to enable it at a later stage, the virtual switch I've created will be deleted. In that same instance, I won't be able to create a new virtual switch as when I get to the end of the operation, the process bar just freezes. To resolve this, I need to disable and re-enable Hyper-V (I can then create a new virtual switch, but it will be subject to the same problem I've mentioned).

Have you encountered this error (if it even is an error) at all? Thanks.
 

My Computer

System One

  • OS
    Windows 8.1 Pro
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Acer Predator G3-605
    CPU
    Intel Core i7 4770 @ 3.4GHZ
    Motherboard
    Acer Predator
    Memory
    16GB DDR3 @ 798MHz
    Graphics Card(s)
    Nvidia GTX 770 2GB - Personally Overclocked
    Sound Card
    N/A
    Monitor(s) Displays
    Acer Pradator full HD LED 24''
    Screen Resolution
    1920 x 1080
    Hard Drives
    Corsair Neutron GTX 240 GB (Boot)
    2 TB Seagate
    PSU
    500W
    Case
    Acer Pradator G3-605
    Cooling
    All standard
    Keyboard
    Corsair Raptor K50 RGB
    Mouse
    Acer Optical Mouse
    Internet Speed
    40Mbps
    Browser
    Chrome
    Antivirus
    Bitdefender Windows 8 Security

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
I don't see any reason to disable the Hyper-V nor have I ever done it, I do not even understand why someone would want to disable it. Disabling Hyper-V has none whatsoever impact in functionality, reliability or speed of Windows, it does not save any resources, it does not make Windows boot or work faster. For me enabling Hyper-V is always the first thing I do after Windows is installed and then it remains enabled.

However, if you for any reason decide to disable Hyper-V, the correct way to do this is of course first delete / remove the virtual switches from Hyper-V > Virtual Switch Manager, and first when they have been correctly removed from the system, disable the Hyper-V features. In this way there will be no issues in recreating the virtual switches when Hyper-V will once again be enabled.

Kari
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Computer type
    Laptop
    System Manufacturer/Model
    HP ENVY 17-1150eg
    CPU
    1.6 GHz Intel Core i7-720QM Processor
    Memory
    6 GB
    Graphics Card(s)
    ATI Mobility Radeon HD 5850 Graphics
    Sound Card
    Beats sound system with integrated subwoofer
    Monitor(s) Displays
    17" laptop display, 22" LED and 32" Full HD TV through HDMI
    Screen Resolution
    1600*900 (1), 1920*1080 (2&3)
    Hard Drives
    Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
    External: 2TB for backups, 3TB USB3 network drive for media
    Cooling
    As Envy runs a bit warm, I have it on a Cooler Master pad
    Keyboard
    Logitech diNovo Media Desktop Laser (bluetooth)
    Mouse
    Logitech MX1000 Laser (Bluetooth)
    Internet Speed
    50 MB VDSL
    Browser
    Maxthon 3.5.2., IE11
    Antivirus
    Windows Defender 4.3.9431.0
    Other Info
    Windows in English, additional user accounts in Finnish, German and Swedish.

rowlands111

Member
Member
Delete and remove the virtual switch first, got it! Thank you.

I notice a, albeit very tiny, footprint from Hyper-V being enabled. My applications take an extra split second to start up (hah).

Thank you again for the sound advice and giving me the correct procedure, I wouldn't have come upon it otherwise.
 

My Computer

System One

  • OS
    Windows 8.1 Pro
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Acer Predator G3-605
    CPU
    Intel Core i7 4770 @ 3.4GHZ
    Motherboard
    Acer Predator
    Memory
    16GB DDR3 @ 798MHz
    Graphics Card(s)
    Nvidia GTX 770 2GB - Personally Overclocked
    Sound Card
    N/A
    Monitor(s) Displays
    Acer Pradator full HD LED 24''
    Screen Resolution
    1920 x 1080
    Hard Drives
    Corsair Neutron GTX 240 GB (Boot)
    2 TB Seagate
    PSU
    500W
    Case
    Acer Pradator G3-605
    Cooling
    All standard
    Keyboard
    Corsair Raptor K50 RGB
    Mouse
    Acer Optical Mouse
    Internet Speed
    40Mbps
    Browser
    Chrome
    Antivirus
    Bitdefender Windows 8 Security

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
You are welcome :).
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Computer type
    Laptop
    System Manufacturer/Model
    HP ENVY 17-1150eg
    CPU
    1.6 GHz Intel Core i7-720QM Processor
    Memory
    6 GB
    Graphics Card(s)
    ATI Mobility Radeon HD 5850 Graphics
    Sound Card
    Beats sound system with integrated subwoofer
    Monitor(s) Displays
    17" laptop display, 22" LED and 32" Full HD TV through HDMI
    Screen Resolution
    1600*900 (1), 1920*1080 (2&3)
    Hard Drives
    Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
    External: 2TB for backups, 3TB USB3 network drive for media
    Cooling
    As Envy runs a bit warm, I have it on a Cooler Master pad
    Keyboard
    Logitech diNovo Media Desktop Laser (bluetooth)
    Mouse
    Logitech MX1000 Laser (Bluetooth)
    Internet Speed
    50 MB VDSL
    Browser
    Maxthon 3.5.2., IE11
    Antivirus
    Windows Defender 4.3.9431.0
    Other Info
    Windows in English, additional user accounts in Finnish, German and Swedish.

radup

New Member
VM

Hi,

I created a VM on a local server using Hyper-V and installed on it Windows Server 2012 R2. All works fine and it's installed correctly.
I just want to know if it's possible for other users that have acces to that local server (i mean people that use own computers/laptops) to connect to that VM I created.

Thanks,
Radu
 

My Computer

System One

  • OS
    Windows Server 2012 R2
    Computer type
    PC/Desktop

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
Hi,

I created a VM on a local server using Hyper-V and installed on it Windows Server 2012 R2. All works fine and it's installed correctly.
I just want to know if it's possible for other users that have acces to that local server (i mean people that use own computers/laptops) to connect to that VM I created.

Thanks,
Radu
Hi Radup, welcome to the Eight Forums.

The easiest way would be to allow Remote Desktop Connections on your guest, the vm, and let people connect to it. See this tutorial at our sister site the Ten Forums, it applies as it is also to Windows 8.1: RDC - Connect Remotely to your Windows 10 PC - Windows 10 Forums. Networked virtual machines are in every sense as any other networked computers and they can be used over the remote desktop connection.

You can also use Hyper-V Virtual Machine Connection application to connect to any Hyper-V server in your network, but that's somewhat more complicated and currently not covered in this or other Eight Forums tutorials.

Kari
 
Last edited:

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Computer type
    Laptop
    System Manufacturer/Model
    HP ENVY 17-1150eg
    CPU
    1.6 GHz Intel Core i7-720QM Processor
    Memory
    6 GB
    Graphics Card(s)
    ATI Mobility Radeon HD 5850 Graphics
    Sound Card
    Beats sound system with integrated subwoofer
    Monitor(s) Displays
    17" laptop display, 22" LED and 32" Full HD TV through HDMI
    Screen Resolution
    1600*900 (1), 1920*1080 (2&3)
    Hard Drives
    Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
    External: 2TB for backups, 3TB USB3 network drive for media
    Cooling
    As Envy runs a bit warm, I have it on a Cooler Master pad
    Keyboard
    Logitech diNovo Media Desktop Laser (bluetooth)
    Mouse
    Logitech MX1000 Laser (Bluetooth)
    Internet Speed
    50 MB VDSL
    Browser
    Maxthon 3.5.2., IE11
    Antivirus
    Windows Defender 4.3.9431.0
    Other Info
    Windows in English, additional user accounts in Finnish, German and Swedish.

yu gnomi

New Member
Member
When I run Hyper V manager normally or as administrator, I am unable to create an external switch, the option isn't available to me.
Virtual Switch.png
rest of tip is I may not have access to the network adapter. How do I fix this?
 

My Computer

System One

  • OS
    Win 8.1 Pro
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Home Built
    CPU
    Intel i5-4590
    Motherboard
    MSI h97 PC Mate
    Memory
    Kingston Valu Ram 2 x 8 gb
    Graphics Card(s)
    Radeon r7 265
    Monitor(s) Displays
    Viewsonic 22" flat display
    Screen Resolution
    1920 x 1080
    Hard Drives
    Samsung 250 gb 840 evo SSD,
    WD Blue 1 TB HD,
    Fantom 2 TB ext HD
    PSU
    Corsair 600 W
    Case
    Antec 1
    Cooling
    stock CPU cooler, 4 x case fans, GPU fan and P/S fan
    Keyboard
    HP ps/2 keyboard
    Mouse
    Logitech Trackman Marble
    Internet Speed
    50 mb/s
    Browser
    Chrome
    Antivirus
    Norton Security Suite

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
That error message is usually only shown when the host machine has no network adapters.
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Computer type
    Laptop
    System Manufacturer/Model
    HP ENVY 17-1150eg
    CPU
    1.6 GHz Intel Core i7-720QM Processor
    Memory
    6 GB
    Graphics Card(s)
    ATI Mobility Radeon HD 5850 Graphics
    Sound Card
    Beats sound system with integrated subwoofer
    Monitor(s) Displays
    17" laptop display, 22" LED and 32" Full HD TV through HDMI
    Screen Resolution
    1600*900 (1), 1920*1080 (2&3)
    Hard Drives
    Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
    External: 2TB for backups, 3TB USB3 network drive for media
    Cooling
    As Envy runs a bit warm, I have it on a Cooler Master pad
    Keyboard
    Logitech diNovo Media Desktop Laser (bluetooth)
    Mouse
    Logitech MX1000 Laser (Bluetooth)
    Internet Speed
    50 MB VDSL
    Browser
    Maxthon 3.5.2., IE11
    Antivirus
    Windows Defender 4.3.9431.0
    Other Info
    Windows in English, additional user accounts in Finnish, German and Swedish.

yu gnomi

New Member
Member
I has one
NetAdapter2.png

and an extra one that has Hyper-V in it's name
NetAdapter1.png

the Hyper-V one says it is disabled (code 22). Would enabling or uninstalling the Hyper-V controller be called for?
 

My Computer

System One

  • OS
    Win 8.1 Pro
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Home Built
    CPU
    Intel i5-4590
    Motherboard
    MSI h97 PC Mate
    Memory
    Kingston Valu Ram 2 x 8 gb
    Graphics Card(s)
    Radeon r7 265
    Monitor(s) Displays
    Viewsonic 22" flat display
    Screen Resolution
    1920 x 1080
    Hard Drives
    Samsung 250 gb 840 evo SSD,
    WD Blue 1 TB HD,
    Fantom 2 TB ext HD
    PSU
    Corsair 600 W
    Case
    Antec 1
    Cooling
    stock CPU cooler, 4 x case fans, GPU fan and P/S fan
    Keyboard
    HP ps/2 keyboard
    Mouse
    Logitech Trackman Marble
    Internet Speed
    50 mb/s
    Browser
    Chrome
    Antivirus
    Norton Security Suite

yu gnomi

New Member
Member
Enabled the Hyper-V controller in Device Manager, still unable to create a virtual switch. Re-booted, no change.

Disabled and then attempted to uninstall the Hyper-V controller, it remained. Rebooted, and retried, no difference. I am back at same point when I first posted in this thread.

edit: I don't know if this matters, but I believe that the Hyper-V NIC appeared after I used a specific feature in Visual Studio 2013 - namely the Windows Phone emulator (for developing universal apps that will work on Windows Phone and presumably any more powerful device).

I disabled it afterwards because Chrome stopped working, and I believed that Chrome was attempting to use that controller to access the internet. Chrome went back to working after I disabled it.
 
Last edited:

My Computer

System One

  • OS
    Win 8.1 Pro
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Home Built
    CPU
    Intel i5-4590
    Motherboard
    MSI h97 PC Mate
    Memory
    Kingston Valu Ram 2 x 8 gb
    Graphics Card(s)
    Radeon r7 265
    Monitor(s) Displays
    Viewsonic 22" flat display
    Screen Resolution
    1920 x 1080
    Hard Drives
    Samsung 250 gb 840 evo SSD,
    WD Blue 1 TB HD,
    Fantom 2 TB ext HD
    PSU
    Corsair 600 W
    Case
    Antec 1
    Cooling
    stock CPU cooler, 4 x case fans, GPU fan and P/S fan
    Keyboard
    HP ps/2 keyboard
    Mouse
    Logitech Trackman Marble
    Internet Speed
    50 mb/s
    Browser
    Chrome
    Antivirus
    Norton Security Suite
Top