VirtualBox Ubuntu guest: alternating between network adapters at home/office

0

Edit: Added a use case for CIFS

Setup:

  • Host: Windows 7 SP2 64bit
  • Guest: Ubuntu 12.04.3 LTS 64bit (on VirtualBox 4.3.0)
  • The host laptop has a 2 network adapters:
    • A USB-pluggable WiFi module
    • An 1Gbps ethernet port

Use cases:

  • When working at the office, the USB WiFi module is connected to the host. The Ubuntu guest needs connectivity with a fixed IP configuration (A fixed IP on the 192.168.1.x network, DNS is 8.8.8.8)

  • When working at home, the USB Wifi module is absent, and the Ethernet port on the host is used. The network at home has a DHCP server (my home router) which I want to use in order to assign IP configuration for the Ubuntu guest.

  • In both cases, I want the Ubuntu guest to work in "Bridged" mode (bridge the virtual eth0 and/or eth1 to the host's currently-used physical network adapter).

  • I need the host the guest to communicate over CIFS (samba) which I think prevents me from using NAT (?)

  • Unfortunately, I noticed that when the USB WiFi is disconnected from the host, VirtualBox automatically switches the physical device used for "virtual network interface 1" to the Ethernet port.

My question:

When working either at home or at the office (that is: either with the USB WiFi connected and the Ethernet disconnected, or the other way around), I want to have Internet connectivity on the VirtualBox, without the need to manually change the configuration every time.

  • What configuration should I use in VirtualBox?

  • What configuration should I use in the guest? Specifically, in /etc/network/interfaces, in /etc/udev/rules.d/70-persistent-net.conf

  • Also, does the guest need any specific IP routing rules so that traffic is routed through the (always single) available guest interface?

  • Does a specific configuration of bridging host interfaces (Use Windows to bridge the Wifi and Ethernet adapters) help in any way? What are the VirtualBox and guest configurations in this case?

montigo

Posted 2013-12-03T13:12:17.680

Reputation: 11

Why aren't you using NAT, which would solve the issue ? – jlliagre – 2013-12-03T14:41:33.763

I want the host & the guest to communicate using Samba (CIFS), is this possible using NAT? I will edit the question accordingly. – montigo – 2013-12-04T09:05:56.190

Answer updated too. – jlliagre – 2013-12-04T10:51:43.133

Answers

0

NAT allows incoming connections when configuring port forwarding but as far as I know, this won't work with CIFS at least if you want a CIFS servers on the guest side.

If you just want your guest to be a CIFS client and the server to be on the host, NAT might just work.

In any case, what I would do is configuring two interfaces on the guest.

  • The first one would use NAT so allow Internet connection.

  • The second one would use a "Host Only" network, i.e. vboxnet, and will allow unrestricted bidirectional communication between the host and the guest.

jlliagre

Posted 2013-12-03T13:12:17.680

Reputation: 12 469