Setting up internet access on Ubuntu HyperV Virutal Machine

There are many way to get a new linux VM speaking to the external world. But I wanted a solution that was quick, would leave the VM in its own private network and still be able to access the internet (both in the VM and on the laptop). The plan was to use this VM or network of VMs to install Nodejs and try various node modules out. This way my laptop does not get crowded with node modules over time. These are the steps I've followed and takes me about 2 to 3 minutes to complete:


1. Creating a new Internal adapter in HyperV

a. In Virtual Switch Manager, select 'New virtual network switch' and select 'Internal' for the type of virtual switch

b. Click 'Create Virtual Switch'

c. Give it a Name, I've called it 'SchubertSwitch' and don't check 'Enable virtual LAN ...'

d. Click Apply

e. In the new VM properties, under Network Adapter make sure Virtual Switch points to this new switch

The name of the virtual switch is important, as this creates an actual adapter under 'Network Connections'. The adapter name should be vEthernet (<your switch name>), in my case 'vEthernet (SchubertSwitch)'


2. The Adapter

a. Locate the adapter by opening Explorer in Windows 10 and browsing to 'Control Panel\Network and Internet\Network and Sharing Center' and clicking on 'Change adapter settings' on the left

b. In the properties of the new adapter, double click 'Internet Protocol Version 4 (TCP/IPv4)'

c. Click 'Use the following IP Address' and for the IP enter and mask I've used range here as it is a private IP range

d. Click 'Use the following DNS server address' and under Preferred DNS server enter your router IP. This can be found at the back of the router and is usually like or can be located by running 'ipconfig' command and looking for the Default Gateway of your current internet connection on your laptop

e. Click 'Advance' and add another random IP from the router range this time, like, subnet This is so our new adapter can handle communications between both the networks, the new private network 172.30.*.* and existing router network 192.168.0.*

f. Click 'OK' to the IPv4 properties dialog and 'OK' to the adapter properties

g. Complete the NAT setup by running the below powershell script in administrator mode:

New-NetNat -Name NatFor172 -internalipinterfaceaddressprefix


3. In Ubuntu 18.04 VM

a. Search for Settings and select Network. Turn the Wired connection On and click the little cog beside it

b. Choose the IPv4 tab

c. Choose Manual under IPv4 Method

d. Addresses:,,

e. DNS:, this IP is the Default Gateway or the router ip we found earlier. Turn automatic off above DNS

f. Click Apply and restart the VM


*. The Firewall 

a. Allow the new IP range, in this case as 'Home' range. Depend on your firewall, this might need some researching on the internet. The best way to be sure the firewall is blocking the internet on the VM is to turn it off for a few minutes and use the browser in the VM


All done!


Now that the new Ubuntu 18.04 VM can speak to the internet and is in it's own private network, I've gone ahead and upgraded it and installed Node.js using the below:

sudo apt update

sudo apt upgrade

sudo apt install npm


and finally, ...

node -v

npm -v 


Other topics you might like: