Windows 8 Hyper-V - how to give VM internet access?

212

68

I've got Windows 8 Pro on my home machine. I want to have a Windows 7 Professional VM running under Hyper-V, and I want the VM to have full internet access. My physical machine has a wireless network adapter I use to connect to a router.

Here's what I've done so far:

  • In Hyper-V Manager, I've created a new External Virtual Switch, which is connected to my wireless network adapter. If I look in Windows 8's Network Connections page, I can see it's created a virtual ethernet adapter and a network bridge, and my wireless adapter is now bridged.

  • I've created a Windows 7 VM, and in the Hyper-V settings I've set it to use the virtual switch.

When I log into the VM, I have a network, but it's "unidentified" and has no internet access. What am I missing? Is it something to do with the "VLAN identification" settings? I'm not quite sure what these are about.


This question was a Super User Question of the Week.
Read the blog entry for more details or contribute to the blog yourself

Graham Clark

Posted 2012-09-04T06:20:36.667

Reputation: 2 493

@Kronos - How & where in Windows 8.1 can one assign a Static IP to the Host Machine (with an External Virtual Switch)? It was easy to do so with the HV VM, but the static IP on the Physical Host Adapter seems to be gone and cant use it to access Host via RDP anymore. Direction please? – Alex S – 2016-11-29T13:20:15.240

Answers

264

In order to get the VM connected to the internet you have to tie it to the Ethernet/Wireless NIC Card. In order to do this you have to create a "Virtual Switch".

  1. Open your Hyper-V Manager
  2. Select Action --> Virtual Switch Manager

    Accessing the VM Switch Manager

  3. Select External and then Create Virtual Switch

    Virtual Switch Manager

  4. Give the Switch a Name and then select the External Controller you use to connect to the internet (Ethernet, or Wireless NIC, etc,.)

    Note: You must select the way that you are actually connecting to the internet. IE, if your computer is set up to use Wifi or Ethernet, but is currently using Ethernet, you must use Ethernet - the Wifi connection will not work because the host machine isn't currently using it.

    VM Switch Properties

  5. Select Apply and then OK

  6. Right click on the Virtual Machine you want to connect and select Settings

    VM Settings

  7. Under the Network Adapter Setting select the newly created Virtual Switch

Connecting the Switch to the VM

This should enable the connection you use to connect to the internet to be accessible to the VM


Note: you may have to do a ipconfig /release and ipconfig /renew (Windows) or a sudo dhclient -v -r and sudo dhclient -v (Linux) on the remote machine to get it to renew its DHCP settings and retrieve an IP address.

James Mertz

Posted 2012-09-04T06:20:36.667

Reputation: 24 787

1I've done this before and lost internet access. Googled, came here, removed everything and followed these instructions. Lost internet access again because the creation of the switch didn't take over my DNS servers. I had to ncpa.cpl -> WLANswitch properties and manually add them again in IPv4 settings (W8.1 Enterprise x64) – Jakke – 2015-01-09T01:48:38.813

I couldn't add a new virtual switch to the desired network adapter since I was already bound to a virtual switch and for some reason it doesn't allow more than one binding. It shouldn't be a problem though since te existing binding/virtual switch is already of the type External. The Windows 7 VM still isn't able to access the Internet with it though - but it does recognize the switch. – Bent Rasmussen – 2015-05-14T14:37:31.897

I just solved the problem for my part by adding a legacy network adapter to the virtual machine (older network card) - for some reason that made a difference. That is dispite the fact that Hyper-V integration services were already running on the VM, so it shouldn't have been necessary! Well, it was solvable, but kind of a crappy experience. – Bent Rasmussen – 2015-05-14T15:02:45.883

best description ever :) – juFo – 2015-05-17T10:08:09.587

1I tried this on both Wired and wireless connections but get limited connectivity. It's not getting an IP address. DHCP, doesn't seem to be working. If I set manually the IP, DNS, and default gateway on the client, it works. – Rick – 2015-05-21T15:27:16.403

1One of the best, thoughtful, step-by-step posts I've seen. Thanks for taking the time and effort to put this answer together! – code4life – 2015-08-02T17:17:09.987

After adding the virtual network network switch in the Virtual Switch Manager I had to close the Virtual Machine Connection window and the Hyper-V manager window and reopen them. After that I was able to associate the new switch with the VM. – Martin Eden – 2016-05-12T12:25:44.957

Creating the new switch worked for me. I was trying to use existing switches and for some reason it was not working. – Aster Veigas – 2017-02-27T07:25:19.723

excellent, excellent post with clear pictures... I'd stupidly plugged in my network card and forgot to change the source on my switch! running through this I realized, and now have 2 switches that I can switch between (pardon the pun) - I've upvoted this, if I could upvote more I would and also send cake – Pete – 2017-07-10T11:23:41.503

THANK YOU for the sudo dhclient bit! I've been tinkering around with my settings for a full day because the external switch just plain wouldn't work, but running those commands from the guest OS fixed it! :) – Deep-B – 2017-09-05T08:36:08.820

The last commands helped me out. – Devid – 2018-05-23T18:35:32.423

10This is a great description, but it's exactly what I did. I did manage to get it all working though, I'll check at home this evening and either add an answer or mark someone as correct. – Graham Clark – 2012-09-12T10:44:15.627

5Not exactly sure how I got it working, I think I'd ticked the "Enable virtual LAN identification" box and then unticked it whilst the VM was running - for some settings like this, the VM needs to be off/restarted to take effect. – Graham Clark – 2012-09-13T19:37:47.873

i had to uninstall virtualpc2007 otherwise my physical network stopped working after step4/5 – wal – 2013-02-07T23:17:02.187

works flawlessly!!! so nice of you for great answer. – TheVillageIdiot – 2013-10-09T05:46:33.700

This procedure installed a network bridge under "Control Panel\Network and Internet\Network Connections". Every time I boot the VM I have to disable then enable the bridge (via its right-click menu). I've read similar accounts from others. Hope they get it ironed out. – Vimes – 2014-01-09T02:37:08.450

7Anyone looking for the "Switch Manager" it's no longer under Action - instead right click the computer name (in the left area) – Benjamin Gruenbaum – 2014-01-15T09:11:08.660

23

I had to disable and then re-enable the Allow management operating system to share this network adapter under the Virtual Switch Manager.

If this isn't checked the host machine will not be able to use the chosen adapter. It had been checked in my case, for some reason I had to flip it back and forth again.

R Horne

Posted 2012-09-04T06:20:36.667

Reputation: 331

14WARNING - Doing this on a remote server will completely kill the connection as soon as you untick this. I found out the hard way :( – Piotr Kula – 2014-09-23T20:05:50.677

@PiotrKula In that case you do a: Get-VMSwitch and then a Set-VMSwitch -Name <swtch-name> -AllowManagementOS $True on a powershell console. Just for future reference! ;) – NoOne – 2020-01-25T09:34:10.353

I had to disconnect & connect my wireless connection after disable & enable step. – Joy George Kunjikkuru – 2014-04-25T05:56:58.507

6

Another trick as detailed in this question Windows 8 Hyper-V network not working on host is that this may not work over wireless... re did the setting several times nothing - set up an ethernet adapter - worked straight away. [quick edit to say of course I'd set up separate virtual switches for the two physical adapters...]

Mike Walsh

Posted 2012-09-04T06:20:36.667

Reputation: 133

6

Without rebooting I managed to get it working with a wireless adapter, which otherwise was doing nothing.

Open the network connections control panel

You'll see the virtual adapter setting has created a network bridge.

enter image description here

Right click on your Wi-Fi adapter (the one with the signal strength icon) and select Connect/Disconnect

Then you have to click the On switch that comes up in the sidebar and select your network. For some reason it was Off even though I was online before.

enter image description here

Everything then magically lit up and I was able to access the internet from within my Win XP VM immediately.

enter image description here

Simon

Posted 2012-09-04T06:20:36.667

Reputation: 592

5

In my case, while the VM was running I changed the virtual Switch settings to “Not Connected” and then back to my newly created virtual switch. Worked.

user215043

Posted 2012-09-04T06:20:36.667

Reputation: 51

1"Hullo, IT! Have you tried plugging it off & on again?" – Michael Blackburn – 2016-10-11T14:31:22.187

3

Recent Hyper-V versions have a virtual adapter called "Default Switch", that is preferable to be used by the VM. It does a complex internal routing to allow machines to work. Just connect your VM's to it and it should work.

Alternatively to connect the VM to the Internet via a WiFi network you can use an "Internal" Virtual Switch. On the screenshot I use Ethernet, but it works with WiFi too. Internal switches do not expose your VM to the Internet, so they is the best solution in general.

Basically you need to create an Internal virtual switch and connect your VM's adapters to it, then use the OS's Share internet connection feature.

All steps in screenshots:

Create internal switch

Then from Adapters in Control panel share your Internet connection (any adapter works).

Share Internet connection

Sometimes (usually after Windows update) the VM loses the connection although everything seems properly setup. In such case you need to turn off the Internet sharing and then enable it again. You don't need to restart.

venimus

Posted 2012-09-04T06:20:36.667

Reputation: 382

This is the only solution that worked for me! I spend hours trying to installing and uninstalling Hyper-V and Docker. Thank you! – Mikael Chudinov – 2018-05-24T10:09:19.930

This completely killed the connection to the hyper-v server, thanks. – linux_newbie – 2019-10-14T10:08:26.323

ockquote>

Sometimes (usually after Windows update) the VM loses the connection although everything seems properly setup. In such case you need to turn off the Internet sharing and then enable it again.

Did you try that? – venimus – 2019-10-14T12:09:19.590