Connect to external VPN from an Ubuntu Guest machine on VirtualBox

2

I have the folding VirtualBox setup:

  1. My host machine running a Kubuntu 14.04.
  2. My guest machine is running Kubuntu 14.04 as well.

My host machine is connected to office A’s LAN and has access to internet (all ports opened), and I have a VPN PPTP configured on it that is connecting nicely to my employer’s office B's LAN.

I installed the guest machine of Kubuntu 14.04 to get a working environment different than my main host machine’s Kubuntu 14.04.

What I want to achieve is to have:

  1. The host machine running Kubuntu 14.04 connected to my office A’s LAN.
  2. The guest machine running Kubuntu 14.04 to connect to office B’s LAN.

I am a bit lost on how to set that up, because my networking skills are limited.

Ant

Posted 2014-11-12T05:03:26.587

Reputation: 123

What is “B”? You mention it but don’t explain it. – JakeGould – 2014-11-12T06:54:45.467

1@JakeGould Yes, Sorry I did a typo. I edited the question. – Ant – 2014-11-12T07:43:52.837

Okay, very clear now. I believe the issue is you need to setup a bridged connector for your networking on the guest install of Kubuntu 14.04. Just launch VirtualBox & adjust the settings for that machine from NAT to Bridged and it should work. Posted a more detailed answer as well. – JakeGould – 2014-11-12T07:58:50.450

Answers

3

So basically you have a host and a guest machine—both running Kubuntu 14.04—sharing a network connection that you want to connect to two different VPN’s, correct?

The issue I see is by default, VirtualBox is set to internally—within it’s own software networking code—NAT any guest connection based on the host connection’s network settings. Meaning for all intents and purposes, both your guest as well as host will be on the same network address sharing the same connection; with the guest really being subordinate to the host as far as the main connection goes.

I believe the best bet is to set the network connection on the guest install of Kubuntu 14.04 to a bridged networking connection as described here; emphasis mine:

When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.

And explained even more clearly here; again emphasis is mine:

Under the Bridged Adapter, your virtual machines behave as any other computer on the network where the hosting system resides; it bridges the virtual and physical networks. The outside world can directly communicate with the guest machine.

That is the key. You want your guest connection to have an independent network connection outside of the host machine’s VPN so it can connect to it’s own VPN or anything else outside of the host machine’s VPN.

Meaning, with NAT your network addresses for host and guest would be something like this when connected to your router as far as the outside world is concerned; using the subnet 123.456.789.x as an example:

  • Kubuntu 14.04 Host: 123.456.789.0
  • Kubuntu 14.04 Guest: 123.456.789.0

But with bridged mode set for the guest, your guest machine can grab a unique IP address from the router so the IP addresses could look like this with the guest in bridged mode:

  • Kubuntu 14.04 Host: 123.456.789.0
  • Kubuntu 14.04 Guest: 123.456.789.1

And that division between IP addresses is what I believe is the the key to allowing you to setup two independent and unique VPN connections on your setup.

JakeGould

Posted 2014-11-12T05:03:26.587

Reputation: 38 217