Setting up a virtual switch for a Hyper-V
network
March 29, 2013 lennyankireddi Leave a comment Go to comments
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
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"
Gave the switch a name and chose not to use a VLAN identifier for the host operating system.
Clicked on "OK"
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.
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.
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.
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".
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.
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.
ipconfig now shows the following output
And the multiplexor network bridge properties show the following
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.