Project

General

Profile

Feature #594

VirtualBox Host-Only Network With Internet Access

Added by Daniel Curtis over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Virtualization
Target version:
Start date:
04/11/2015
Due date:
% Done:

100%

Estimated time:
0.50 h
Spent time:

Description

I use VirtualBox for a lot of development on my laptop, and as such I do not always have Internet access; and not always connected via ethernet. For the primary network interface, I use a Host-only network type to connect with the VMs when disconnected from the Internet; however I also need Internet access when I am connected via WiFi or ethernet. To do this just add a second network interface to the VM in use and make sure to sure set the network type to NAT.

VirtualBox GUI

In this example the host-only network is called vboxnet0, and I configured the network to another network instead of the default 192.168.56.0 network.

  • Configure the Host-only network in VirtualBox -> File -> Preferences -> Network -> Host-only Networks and click [+] Add host-only network. Click OK when finished.
  • Configure the primary network interface for the VM by going to Settings -> Network Adapter 1 and change Attached to to Host-only Adapter, then change the Name to vboxnet0.
  • Configure the secondary network interface for the VM by going to Settings -> Network Adapter 2 and change Attached to to NAT.
  • Click OK when finished.

Now the VM will have two interfaces; one for the connection to the host machine and one to connect to the Internet using NAT. Keep in mind that the VM will need to have the extra network interface configured accordingly or else network connectivity will not work as expected.

VBoxManage

In this example the host-only network is called vboxnet1, and I configured the network to another network instead of the default 192.168.56.0 network.

  • Create the Host-only network interface:
    VBoxManage hostonlyif create
    
    • Example output
      0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
      Interface 'vboxnet1' was successfully created
      
  • Set the host-only network interface IP address:
    VBoxManage hostonlyif ipconfig vboxnet1 --ip 192.168.88.1
    
  • (Optional) Setup a DHCP server for the host-only network:
    VBoxManage dhcpserver add --ifname vboxnet1 --ip 192.168.88.1 --netmask 255.255.255.0 --lowerip 192.168.88.100 --upperip 192.168.88.150 --enable
    
  • Configure the primary network interface for the VM
    VBoxManage modifyvm "ExampleVM" --nic1 hostonly --hostonlyadapter1 vboxnet1
    
  • Configure the secondary network interface for the VM
    VBoxManage modifyvm "ExampleVM" --nic2 nat
    

Now the VM will have two interfaces; one for the connection to the host machine and one to connect to the Internet using NAT. Keep in mind that the VM will need to have the extra network interface configured accordingly or else network connectivity will not work as expected.

Resources

#1

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
  • % Done changed from 0 to 50
#2

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100
#3

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis over 9 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF