VirtualBox – Access Internet from Guest Machine

Oracle VirtualBox is a free, open source and powerful virtualization tool. Some minor configurations tweaks are required to access guest localhost from host computer. I am running VirtualBox with Ubuntu on my MAC OS.

If you are attempting to access internet from your virtual machine, but if you are getting error, then here are few steps that you can try. In my scenario, I also wanted to access guest localhost from host system. I was able to access internet from the virtual machine after these steps:

  • Shut down virtual machine
  • In VirtualBox, right click on the virtual machine and go to “Settings
  • Select “Network” tab
  • Select “Adapter1
  • Select “Enable Network Adapter” checkbox
  • Click on “Attached to” drop down box and select “NAT
  • Select “Adapter2
  • Select “Enable Network Adapter” checkbox
  • Click on “Attached to” drop down box and select “Host-only Adapter
  • Next, go to “Advanced” section
  • Click on “Promiscuocus Mode” drop down box and select “Allow VMs
  • Finally, launch virtual machine

Now, open command prompt or terminal window and type command: ls /sys/class/net/ to see all your network adapters. In my case, I have enp0s3 and enp0s8 along with lo. Note down the names (ignore lo for now).

Using command prompt edit and update /etc/network/interfaces file. After updating the file should look something like this:

You can now reboot the virtual machine and try to access the internet, it should work. To test from command prompt, use command: ping google.com

Leave a Reply

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