Project

General

Profile

Feature #594

Updated by Daniel Curtis over 9 years ago

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*. 

 h2. 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. 

 h2. 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_ 
 <pre> 
 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% 
 Interface 'vboxnet1' was successfully created 
 </pre> 

 * Set the host-only network interface IP address: 
 <pre> 
 VBoxManage hostonlyif ipconfig vboxnet1 --ip 192.168.88.1 
 </pre> 

 * (Optional) Setup a DHCP server for the host-only network: 
 <pre> 
 VBoxManage dhcpserver add --netname vboxnet1 --ip 192.168.88.1 --netmask 255.255.255.0 --lowerip 192.168.88.100 --upperip 192.168.88.150 --enable 
 </pre> 

 * Configure the primary network interface for the VM 
 <pre> 
 VBoxManage modifyvm "ExampleVM" --nic1 hostonly --hostonlyadapter1 vboxnet1 
 </pre> 

 * Configure the secondary network interface for the VM 
 <pre> 
 VBoxManage modifyvm "ExampleVM" --nic2 nat 
 </pre> 

 h2. Resources 

 * https://www.virtualbox.org/manual/ch06.html#network_hostonly 
 * https://geert.vanderkelen.org/virtualbox-give-host-only-access-to-internet/ 
 * http://precisionsec.com/virtualbox-host-only-network-cuckoo-sandbox-0-4-2/

Back