Connect to external VPN from an Ubuntu Guest machine on VirtualBox

8,447

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.

Share:
8,447
Ant
Author by

Ant

Good day all. Thanks for reading my profile. I am a senior IT PHP / Javascript / AngularJS / NodeJS Web developer. I empathize honesty, respect and high user focused quality control routines in my work ethics.

Updated on September 18, 2022

Comments

  • Ant
    Ant over 1 year

    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.

    • Giacomo1968
      Giacomo1968 over 9 years
      What is “B”? You mention it but don’t explain it.
    • Ant
      Ant over 9 years
      @JakeGould Yes, Sorry I did a typo. I edited the question.