Home > Hyper-V > Setting up a virtual switch for a Hyper-V network

Setting up a virtual switch for a Hyper-V network

This post speaks to how to set up a virtual switch to be used as the network over which several virtual machines can communicate. We start by launching the Hyper-V Manager application and choosing the "Virtual Switch Manager" from the "Actions" menu on the right

clip_image001

There are three types of virtual switches available – External, Internal and Private.

  • External allows you to connect your VMs to each other and to the physical host machine. It requires a physical adapter on the host machine that will be used to communicate with the physical network that the host is connected to.
  • Internal allows communications between the VMs and the host operating system. It does not require a physical adapter on the host machine and will not allow communication with any actual physical network.
  • Private only allows communications between the virtual machines. It does not allow any communication of the VMs with the host operating system.

Setting up an Internal connection type

Since I may require some transfer of information between the host and the guest operating systems, I decided to use the "Internal" virtual switch type. From past implementations, I have seen that you can change the nature of the virtual switch later but will need to restart the Virtual Machines to reflect changes.

Especially if you are switching to or from the "External" type, it will affect the connection on the host because Hyper-V switches out the physical adapter on the host so that the host operating system may start using a virtual adapter as well. This is because the way the networking works is that the host operating system is no longer allow to use the physical adapter on the host machine once an "External" switch has been configured. A new virtual adapter is installed on the host that becomes the outlet of communication for the host OS. The VMs and the host OS all communicate with the virtual switch through their individual virtual adapter which then routes communication to the other machines for internal conversations and out through the physical adapter on the host machine for external communications.

Made the selection and clicked on "Create Virtual Switch"

clip_image002

Gave the switch a name and chose not to use a VLAN identifier for the host operating system. Clicked on "OK"

clip_image003

And that’s all there is to it for an Internal switch type. At this point, a virtual machine configured to use this connection should be able to communicate with other virtual machines configured to use it and the host operating system given the static IP address allocated to the virtual adapter on the VM is in the same subnet as the host.

To understand how to set this up so that files can be interchanged between the guest and the host, refer to this post on the topic.

Now if you wanted to have your virtual machine have the ability to communicate over the physical network on the host, meaning the ability to access the Internet and so on (assuming your host machine can), an "External" switch will be required.

Setting up an External connection type

An important thing to note about the "External" switch is that it affects the network set up on the host machine as well. Once an "External" switch is set up, the host operating system is no longer able to communicate directly with the physical adapter. Instead, all machines, physical and virtual will use a virtual adapter to communicate with the virtual switch which then routes traffic among machines or in and out through the physical adapter.

clip_image004

Setting up an External Connection Type

So to be able to compare the before and after scenario, here’s the state of the network adapters on my host before I used the "External" switch type. This picture represents the set up at the end of the "Internal" switch type configuration above.

clip_image005

The vEthernet adapter is the Virtual Switch that the "VirtualNet" network I set up above uses. Doing an ipconfig yields the following showing that the vEthernet adapter is unconnected and the host OS is currently connected through the WiFi adapter to the physical network.

clip_image006

Now to change the VirtualNet network type to "External", I went back to the Hyper-V Manager, launched the Virtual Switch Manager and selected the existing "Internal" network called "VirtualNet" that I created above. I changed the "Connection Type" to "External network" and selected the adapter from the drop down that is connected to the physical network. Then clicked on "Apply".

clip_image007

The following warning is presented. This is expected because changes are being made to the network adapters on the host machine. Clicked on "Yes" to apply changes.

clip_image008

And here is the after picture. The WiFi adapter now appears bridged through the Network Bridge added to the picture. The vEthernet adapter on the other hand is now connected to the physical network.

clip_image009

ipconfig now shows the following output

clip_image010

And the multiplexor network bridge properties show the following

clip_image011

A virtual machine set up to use this connection now should be able to tunnel through to the physical connection on the host. One thing to ensure is that the virtual machine is able to accept a DHCP assigned IP. If it has a static IP, you may need to switch it to automatically acquire IP and DNS settings. That done, you should be able to browse the Internet through the virtual machine and DNS resolution would work just fine.

Advertisements
  1. May 8, 2013 at 10:27 AM

    Thank you for the Guide, it was very useful, I have a scenario that I hope you can help me with.

    Scenario:
    I am trying to setup a Exchange Test Lab at work which will have a Virtual Machine that has a DNS running on it, My Host machine is connected to my company Domain for internet and it gets the IP automatically from the company DNS Server.

    Question:
    How do I connect to the internet on my Virtual DNS Server while not effecting the company network and only using the virtual switch it for internet?

    Thank you

    • May 9, 2013 at 1:41 PM

      Glad you found it useful. I am not sure what you mean by not affecting the company network but if you need to connect to the Internet from your virtual machine, you will need to use an External network type. When you do this, your virtual switch will get the IP address allocated to your host adapter by DHCP. At this point, your host machine and the virtual machine are both communicating out through a virtual adapter. The behavior of both will be exactly the same. I am not sure if there is a way to isolate the connection to only Internet traffic on your virtual machine.

  2. Rajatchauhan
    September 26, 2013 at 7:34 AM

    dear i am using single Lan card but not be able to connect internet on virtual client..
    i am using external connection on my machine so please suggest me how to work it??

  3. Chofny
    November 4, 2013 at 12:28 PM

    Hello my Name i chofny and i am a student. I have a excersice from school to build up a windows server 2008 and install a active directory with dns and subnetting this ip 173.10.20.1 with the subnetmask 255.255.224.0. But my problem is that after installing windows server 2008 it cant find a lan driver or something. i am using hyper v on windows 8. and i tried some settings. to add a switch but my brain is failing me i dont know al these features liek enabling vlan and sow on. could you please take some time explaining to me what to do and what fucntion is for what? My english isnt that high sow please dont use highclass words XD. thank you in advance.

    I made a switch external on my wireless card from my laptop. it added some other virtual adapters to it and i was able to connect to wifi. i added the switch on my virtual machine and applied it. booted it up and still no lan / wifi adapter. i thought maby it needs a driver sow i watch the device manger and i did saw like 5 items unknow and 1 vmmicrosoft bus thing that didnt worked also. i just removed everything because i was afraid it would screw up my wifi card.

  4. Victor Sperber
    November 10, 2013 at 12:13 PM

    Excellent! Without your explanation I didn’t understand the way the virtual network switch meshed in. I wonder where on the web you found the documentation for this? Keep up the good work!

  5. Ed Bradford
    January 31, 2014 at 6:14 PM

    I have a problem on Win 8.1 Pro. I’ve setup 3 vms and
    loaded operating systems on them. XP, Windows Server 2008 R2
    and Ubuntu. One of the three can connect to the internet.
    Both XP and Ubuntu do not. XP’s problem is that it sends out
    dhcp requests but never sees anything in return, never get
    an IP address and always has the 169… number. WS08R2
    works fine and connects to the internet as does the host.

    I’ve done the following a number of times but cannot figure
    out why the XP virtual machine cannot get a DHCP address.

    0. Integration components installed on both XP and WS08R2
    virtual machines.

    1. With no hyper-v virtual lan equipment (before creating any)
    host machine has working wifi and unused internet adapters.

    2. Wifi properties show no sharing. Clicking either 1 or both
    of the sharing boxes makes the wifi unusable on the
    host; pings no longer work,
    they always time out. By running *ping -t http://www.google.com* I can
    see the pings stopped when I enable sharing and restarting when
    I disable it.

    3. Creating a Virtual Switch in Virtual Switch Manager, leaves
    host connection still working.

    4. Assigning the newly created adapter to an XP virtual machine
    results in no DHCP address being received. VM believes it has
    a network because it sends DHCP requests but receives no
    packets.

    5. Assigning the newly created adapter to a Windows Server
    2008 R2 virtual machine results in a successful internet
    connection. WS08R2 correctly speaks to the Intneret.

    6. Assigning the newly created adapter to the Ubuntu image also
    produces the no network connectivity issue, but I am not certain
    this problem is the same as the XP virtual machine problem.

    Any wisdom or guidance would be greatly appreciated.

    Ed Bradford
    Pflugerville,TX

  6. Ben
    February 19, 2014 at 2:04 PM

    I am setting up two Hyper-V hosts and have already created external virtual switches. I am trying to figure out if it is advisable to assign a static IPs to these virtual switches versus letting them grab a DHCP address or does it even matter? I’ve assigned static IPs to the NICs on the virtual machines, and have verified that I can communicate externally. Any advice on best practices?

  7. Philsburry
    February 11, 2015 at 8:49 PM

    I would like to thank you for this article. I’ve been trying to create an External virtual switch and always failed. Keep up the great work, and all the best!

  8. January 10, 2016 at 3:48 AM

    This is a great Article . But i ran into a scenario which I cannot resolve
    1. I am using VM Workistation to create a VM Server for Windows 2012 Datacentre Edition
    2. MY Physical PC has only one LAN Card
    3. I have connected the Network Adaptor of the WIndows 2012 VM , to VMnet01, which is a Hold only network
    4. I have installed Hyper-V in the Windows 2012 VM , and created a Windows 2012 Core VM

    It lot looks like Simple:
    Host Physical PC—-> (Inside it)—>VMware Workstation—-> (Inside it)—>Windows 2012 Datacentre Edition —> (Inside it)—>Windows 2012 Core

    I would be want to able to connect my Windows 2012 Datacentre Edition & Windows 2012 Core, but someone i am not able to do it

  1. September 8, 2013 at 3:04 PM
  2. September 28, 2013 at 8:55 PM
  3. May 4, 2014 at 3:48 AM
  4. August 17, 2014 at 10:38 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: