What's new

Weird Hyper-V virtual switch behavior

aag

New Member
I have a Win8-64 system hosting a Win8-32 VM. A physical Wifi adapter provides Internet sharing, and a virtual switch provides Internet access to the guest VM via "internal network".

However, the Win8-64 host seems to be confused as to which adapter provides Internet access. If I delete the virtual switch, the Wifi adapter works fine. If I create a virtual switch, the system works initially fine with both host and guest accessing the internet. However, on wake-from-sleep the host loses Internet access while the VM still retains access!

My "layman diagnosis" is that the virtual switch bypasses somehow the host. I am getting rather desperate about this behavior, and I haven't been able to find any advice via Google. Can somebody enlighten me on how to instruct the host to always poll the physical adapter for Internet access?

many thanks in advance!
 

My Computer

System One

  • OS
    Win8 64bit

aag

New Member
I should mention that of course I could connect the VM through an "external network". But then I would have two different IP addresses for guest and host - which is OK in my home network, but horrible anywhere else. In a hotel, I would have to buy two access codes for guest and host! Hence, NAT is my only viable option.
 

My Computer

System One

  • OS
    Win8 64bit

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
I should mention that of course I could connect the VM through an "external network". But then I would have two different IP addresses for guest and host - which is OK in my home network, but horrible anywhere else. In a hotel, I would have to buy two access codes for guest and host! Hence, NAT is my only viable option.
What an earth are you talking about?

Of course you only have one public (external) IP also when using an external virtual switch. You have completely misunderstood this about virtual switches.

Let me try to explain. A physical Network Interface Controller (NIC) or as it is often called Network Adapter connects your host PC, the physical computer to the network. It can be a LAN NIC or a WLAN NIC, most computers especially laptops today have both available.

Your Hyper-V virtual machine (vm) has no physical hardware, it "borrows" what it needs from host. If you have not removed Network Adapter from vm settings in Hyper-V, it has one but as the machine is virtual all its hardware is virtual, too. Therefore we say your vm is using a virtual NIC.

Of course you can not connect a virtual NIC physically to router or network. That's why you need a virtual switch; a virtual NIC connects itself to a virtual switch, which then connects further to host's physical NIC to allow networking:

Virtual_Switch_12.png

If your PC has both LAN and WLAN, and if you have created an external virtual switch for both NICs you can use both NICs / switches to connect to internet at the same time. I do it all the time: my physical host computer is (when possible) connected with LAN NIC. I have created an external virtual switch which uses the WLAN NIC of the host, and normally my virtual machines use it.

All your public (external) network traffic goes through router (or modem). It gets a public (external) IP from your service provider and then gives local (internal) IPs to each networked device on your network. The system sees no difference if these devices are physical or virtual, each is treated equally.

You can test this easily to see that regardless how many real physical computers or virtual machines you have online at the same time, as long as they connect through same router they all have separate local (internal) IP addresses but all are using the one and same public (external) IP address. Screenshot below shows my computer a few minutes ago; I have a remote desktop connection to my Windows 7 Hyper-V vm which is using an external virtual switch connected to the WLAN NIC on my host, and my host computer is connected with LAN NIC:

VM_Ext_IP.png
(I only blurred a few digits for not to reveal my public IP but you can still see they are the same.)

Theoretically it could be possible to get different public IPs for both LAN NIC and WLAN NIC. It would be possible if both physical NICs on your host would connect to different routers (modems). To do this you would need to do some tweaking, it does not happen by itself. However, using your hotel example, I have traveled a lot and yet I have never seen a hotel where even if you could connect both LAN and WLAN at the same time you would have to pay for two connections. Most hotels only have either LAN or WLAN available and in hotels with both connection types available at rooms they normally belong to the same subnet. You get the access code, give it to PC and that's it. No difference if you connect with LAN or WLAN.

This theoretical possibility totally vanishes if you only use one NIC. If you at a hotel connect wireless using WLAN NIC, and your vm connects to an external switch which uses the same WLAN NIC, all your network traffic from both host and guest are going through the same NIC with just one public IP. The same if you have 10 virtual machines running and online, all of them share the public IP with your host or rather with your router.

Kari
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Name
    Kari The Finn
    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
    Occupation
    Back from retirement, IT consultant
    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.
    Country Flag
    Finland
    State/Region Flag
    de saxony

aag

New Member
Kari, thank you for taking the time to compile an exhaustive response for my benefit! I guess I have expressed myself poorly - I (think that I) understand the concept of virtual NIC. And yet, with an external virtual switch I do end up with my router offering two LAN IP addresses via DHCP: one for the host and another one for the guest. Using an internal virtual switch the host provides an internal IP address through its own DHCP to the guest. Right? Sorry - I may be a bit thick this morning...
 

My Computer

System One

  • OS
    Win8 64bit

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
Yes, two local / internal IPs.

Check What Is My IP Address | Shows Your IP Address both from guest and host and tell me if the public / external IPs really are different? I do not believe it without a screenshot showing both at the same time!

Kari

EDIT:

Check this tutorial, Part 2 Step 3: http://www.eightforums.com/tutorials/19359-hyper-v-virtual-switch-manager.html#post186845

If you do not allow management system to share connection, then you need use separate NICs for vm and host. If this is the case and both NICs are connecting to the Internet using different public IPs (two routers), it is possible to get different public IPs.

Local (internal) IP is of course always different.
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Name
    Kari The Finn
    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
    Occupation
    Back from retirement, IT consultant
    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.
    Country Flag
    Finland
    State/Region Flag
    de saxony

aag

New Member
I will do - but I do not have the laptop at hand right now here (University of Zurich). I should tell you one more complication:
  • After startup, the guest system must connect to a VPN.
  • As a result, I lose RDP connectivity from the host to the guest as soon as the VPN is on. (I can still log to the guest via HyperV terminal).
I believe that I might circumvent these issues by creating two vNICs for the guest, one external and one internal. Do you have any thoughts on this?
 

My Computer

System One

  • OS
    Win8 64bit

Kari

Old geek, new tricks
Team Member
VIP Member
Pro User
OK, jetzt verstehe ich!

When you connect your guest to a VPN it is no longer part of your subnet but instead joins that of the VPN servers. Leaving your subnet and joining that of your Universität Zürich the connection between host and vm is naturally lost if the selection on virtual switch settings I mentioned in my previous post is not checked (I added the tutorial link later, you might not have seen it).

All vm's traffic still goes through your host's NIC but when without VPN it was directly connected to the WAN, now all traffic goes through VPN and your VPN server gives you a public IP. In this case you naturally have two external IPs, the vm uses the same public IP than your host only to VPN and thereafter that of VPN.

You have, as far as I can think of it, two possibilities to maintain WAN connection from your host when connected to VPN:

1. Check the tutorial mentioned in my last post, Part 3 Step 2. If the selection is made the vm shares connection with host and both are connected to WAN even if the vm is connected to VPN. This is the method I recommend for it is so easy; just share virtual switch and as long as your host is connected to WAN, all virtual machines are too.

2. Create two external virtual switches, one connected to WLAN NIC of your host, the other to LAN NIC. Connect your laptop with Ethernet cable, it should now use the external LAN switch for communications. Set vm to use the second external switch, the one connected to WLAN NIC. Connect vm to VPN, use host Internet normally even if the virtual switch vm is using is set not to share connection.

An example of that second alternative above. On host, both LAN and WLAN are connected:

Connections.png

In Virtual Switch Manager I have created an external virtual switch which is connected to WLAN NIC. This switch is set not to share connection:

Virtual_ Switch_ Manager.png

My Windows 7 vm is set to use the non-shared WLAN switch:

vm_settings.png

The vm is connected to a private VPN. Host and vm no longer share the public IP, both online with own IPs:

VPN.png


Something important for you to understand: In your case, as far as to the Universität Zürich VPN both switches are using the same public IP, that of your router. Your VPN only gets the second public IP after it is connected to VPN and uses it thereafter but the VPN server recognizes your connection as coming from the same public IP than your host is using.

My point is still valid: As both switches are connected to NICs which use the same router for connection, you only have one real physical outbound connection from your laptop. This one outbound connection includes then the host and all virtual connections from vms running on it. If you were now at a hotel as you mentioned in your earlier post, you would still cope with one access code to hotel network. If simultaneous connections to LAN and WLAN at hotel were not possible, just select the #1 method mentioned above.

Kari
 

My Computer

System One

  • OS
    Windows 8.1 Pro with Media Center
    Name
    Kari The Finn
    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
    Occupation
    Back from retirement, IT consultant
    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.
    Country Flag
    Finland
    State/Region Flag
    de saxony

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top