Archive

Posts Tagged ‘Networking’

Setting up file sharing between guest and host OS in Hyper-V using an Internal network

March 29, 2013 1 comment

This post talks about making the network configuration settings made on a Hyper-V virtual machine in order to allow file sharing between the virtual machine and host OS. There are 3 types of Hyper-V networks that the virtual machine could be using – Private, Internal and External. Private does not allow any communication except between virtual machines using the same Hyper-V virtual switch. So in order to enable file sharing either an "Internal" or an "External" virtual switch is required.

To learn how to set up an Internal or External virtual switch and the nuances of each, refer here. This post assumes that the VM in question has been configured to use an "Internal" connection type.

On the VM, chose "Network and Sharing Center" > "Change Adapter Settings" to show that we have simple virtual adapter with no connection to any physical network.

clip_image001

Doing an ipconfig on the machine through command prompt shows the adapter is assigned a 169.254.X.X IP which shows it is a limited connection right now. This is because we are using an "Internal" virtual switch type on Hyper-V and are not connected through the physical adapter on the host machine.

clip_image002

So in order to get this virtual machine to be able to communicate with the host, I went about assigning it a static IP address. First, bring up the properties of the adapter from the right click menu.

clip_image003

From the "Ethernet Properties" dialog, selected the "Internet Protocol Version 4 (TCP/IPv4)" option and clicked on the "Properties" button.

clip_image004

When on the IPv4 properties dialog, I need to set a static IP on the adapter that is on the same subnet as the host machine. What this will enable is the ability for the Virtual Switch to route communication between the host and guest operating systems. I chose the IP address shown below because my host machine runs with a 192.168.1.X IP. Set the subnet mask to 255.255.255.0 as shown to ensure same subnet and clicked "OK" to finish.

Now I could have made other settings such as the gateway (which shouldn’t have mattered since there is no physical network connection and Preferred DNS Server which I will eventually have to come back to when I set up the DNS service on this machine. But I am doing the bare minimum here to get the communication working.

clip_image005

On the "Ethernet Properties" dialog, clicked "Close" to apply the settings and move along.

clip_image006

Confirmed that the settings were applied.

clip_image007

Created a new folder called "Transfer" to serve as a go-between for file transfers between the guest and host OS and selected to share it with "Specific people…"

clip_image008

Clicked on "Share" to begin sharing the folder.

clip_image009

The "Network discovery and file sharing" dialog shows up. Selected "No, make the network that I am connected to a private network". It wouldn’t matter greatly because the machine is on an internal network anyway but it is the right choice to make.

clip_image010

Once that is done, the shared folder should be accessible at the path indicated in the screen below. Clicked on "Done" to close out of this.

clip_image011

So let’s try accessing this folder from the host. Opened a file explorer window and type the path shown above in the address bar. The first time connection will require username and password to be typed in. We get away with not using domain specification here because the virtual machine has not been added to a domain yet. If we did, we may have had to use a valid domain user login.

clip_image012

In any case, once authentication is through you are able to view the contents of the folder on the host operating system. Added a file here to complete the test.

clip_image013

And here’s the file on the guest. Besides testing the ability to transfer data, this has also verified the working of the virtual switch.

image

And that’s all there is to that.

Advertisements
Categories: Hyper-V Tags: , ,

Setting up a virtual switch for a Hyper-V network

March 29, 2013 13 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

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.

%d bloggers like this: