Because I'm working on multiple locations, I experience problems with my development servers. Because work on a variety of networks I do not want to configure the networking settings of my virtual machines every time I change network. Sometimes the network requires me to use DHCP. (public libraries and such)
Also I have to change network adapter often, I prefer ethernet but sometimes I have to work wireless.
So a lot of different networks and even different adapters.
Requirements
- Internet connection
- Access Host machine from Guest machine
- Access Guest Machine from Host machine
I am looking for a configuration so I dont have to change my (virtual machines) network settings. Because I had to changed network (adapter)
Specs
host machine: Ubuntu, Virtualbox guest machine: debian. wireless interface: wlp2s0 eth adapter: eth1
Attempt #1
Just use NAT.
- Added a NAT adapter to Virtualbox: (10.0.2.0/24, DHCP enabled)
- Added a NAT adapter to the Guest machine.
- Configure guest interface:
- auto eth1
- allow-hotplug eth1
- iface eth1 inet static
- address 10.0.2.5
- netmask 255.255.255.0
- gateway 10.0.2.2
- network 10.0.2.0
- broadcast 10.0.2.255
With this configuration the following works:
- Internet connection
- Access Host Machine from Guest machine
With this configuration, the following does not work:
- Access Guest Machine from Host Machine
This seems to be a limitation when using NAT.
Attempt #2
NAT in combination with Bridged connection:
- Virtualbox NAT Adapter (10.0.2.0/24, DHCP enabled)
- Virtualbox Bridged Adapter (192.168.56.1/24, DHCP enabled)
Because sometimes I have to switch from wireless to Ethernet I also tried to configure a bridged adapter for both the network adapters on the Host Machine.
Host Machine IP: 192.168.56.101 Guest Machine IP: 192.168.56.100
With this configuration, the following does work:
- Internet connection
- Access Host Machine from Guest machine
With this configuration, the following does not work:
- Access Guest Machine from Host Machine
This example has a problem because for a bridged connection the host machine IP has to be set in the range of the IP range of the bridged adapter. Sometimes I can't because i am required to use DHCP.
Given the details of my attempts, do you guys can advise me a alternative configuration for achieving my goals?