Networking Hyper-V & Linux / Ubuntu virtual machine internet access

You’re probably here because you want a quick and simple way of giving your Hyper-V virtual machine internet access. Look no further, it’ll take you less time than to boil the kettle for a cup of tea.

It’s worth noting this guide is not intended for production environments. You should refer to the Microsoft documentation for setting up secure Virtual Machines.

Prerequisites

If you have already tinkered with your Hyper-V’s Virtual Switch Manager and somehow broken general network connectivity or you’re getting an annoying “Network adapter doesn’t exist”, “You have broken me, go away”, this guide won’t help you.

I suggest you totally uninstall Hyper-V and reinstall it to solve any issues first. Don’t worry though, your existing Virtual Machines will remain BUT do take a backup before doing so!

The getting started checklist:

  1. Internet works on the system that has Hyper-V installed.
  2. There aren’t any weird Firewalls rules or Virus scanners on Windows causing havoc.

Overview

Your virtual machine needs access to your host computer’s internet connection. This is quite simple enough to do.

hyper-v internet connection

We need to:

  1. Create an External Switch on the Hyper-V
  2. Make our Virtual Machine use the External Switch for it’s Network Adapter,
  3. Share your host machines Network Adapter with your External Switch:

hyper-v external switch network sharing

Step 1 – Hyper-V External Switch

Open Hyper-V, open Virtual Switch Managerhyper-v virtual switch manager link

Create a new External Virtual Switch:

hyper v create virtual switch

Fill out the details.

Name: Set a name to whatever you like

Connection Type: Select External network

External Network: Select your host computers Network adapter that has an internet connection.

hyper v create virtual switch - external connection

Great – we have step 1 wrapped up.

Step 2 – VM network adapter

This is a simple step – open the settings for your Virtual Machine.

Select your Virtual Machine from the list in Hyper-V, right click and select Settings:

hyper v virtual machine settings

In the settings window for your Virtual Machine

  1. Select Network Adapter from the left menu
  2. On the right side, click on the Virtual Switch drop down select your External Switch.
  3. Hit OK to save.

hyper v settings network adaptor virtual switch

Step 3 – Host computer internet sharing

This is probably the most important step. The idea is to open the doorway of your host computers internet with the Hyper-V setup.

Technically it’s not bridging, but let’s just loosely use the term bridge. There two islands that need to be connected:

hyper v internet sharing

Open Windows Network Connections.

Hit start, search for ncpa.cpl and hit enter (Windows 10). You can also go to the Windows Control Panel too.

windows network connections ncpa control panel

Your screenshot will look different, i.e. you might have a Wireless adapter instead:Windows network connectios properties for host adapter

Find your main network adapter from the list which has internet. Right click and select Properties.

This will open the Properties window.

Now do the following:

  1. Click the Sharing tab
  2. Tick the highlighted box and select the Hyper-V External Network Switch you created earlier.
  3. Click OK to save

windows network adapter properties internet connection sharing

At this point Windows will reconfigure the network settings for this to take effect.

When this has finished – make sure your host pc’s Windows still works. I.e. Open your favourite browser and check if you can still access websites.

Step 4 – Testing the VM for internet

For this step, simply restart the VM for the network settings to take affect (or restart the networking service, whatever you feel comfortable with).

When your VM comes back up, it should now have internet access. You can check by opening a linux terminal, running the ifconfig to check it’s IP address.

You can also ping a website to check. Alternatively if you’re using a Desktop interface, just fire up a browser and check if you have internet.

 

hyper v network sharing verify linux internet connection

hyper v active internet connection

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.