Virtualbox host and guest network
Versions
- Virtualbox 5.2
- Ubuntu 16
- Ubuntu 18
Problem and Solution
Issues
- Once the VM setup, if chose network adapter “Bridged Adapter” we can easily get network between host and guest, and also access internet inside guest.
- But when we change the laptop from one WIFI network (DHCP) to another network (DHCP), the guest IP will have problem if we still use Bridged Adapter network, as we may referring one guest IP (database guest server) in another guest (app guest server).
Solutions
To solve this problem we need two different network cards for the Virtualbox guest, one “NAT Adapter” network adapter allow guest access external network, and one “Host-only Adapter” to allow guest access other guests and host access this guest.
Config example for Ubuntu 18
- Open Settings for the VirtualBox VM
- Open network, enable one Adapter and select Attached to “Host-only Adapter”
- Re-generate the MAC Address for this adapter
- Enable second Adapter and select attached to “NAT”
- Re-generate the MAC Address for this adapter
-
Start the VM and check the network config by ifconfig -a more - Check the network been config in Ubuntu interfaces, if not need add it and then apply the changes
1 |
|
Config example for Ubuntu 16
- Open Settings for the VirtualBox VM
- Open network, enable one Adapter and select Attached to “Host-only Adapter”
- Re-generate the MAC Address for this adapter
- Enable second Adapter and select attached to “NAT”
- Re-generate the MAC Address for this adapter
-
Start the VM and check the network config by ifconfig -a more - Check the network been config in Ubuntu interfaces, if not need add it and then apply the changes
1 |
|
Now we can access to each other
- From guest to other guests
- From host to guests
- From guest to internet