Share virtual machine VPN connection with real machine

Asked

Viewed 3,127 times

1

I have a problem because I started using a few months ago Ubuntu and now recently migrated to Mint.

Work developing with Java Web but to do tests I need to access the client’s database through a VPN. Unfortunately the installer of this VPN exists only for Windows and Mac. I have tried to configure as certain tutorials but did not work.

So I develop in the Linux environment and certain tests and activity I run in the VM with Windows 7.

I was wondering if there’s any way I could share the connection to VM when she makes use of the VPN with the machine Linux to set up my properties pointing to the company’s database ip.

'Cause when I go on prompt and type ipconfig/all it shows only the bank ip.

Can someone help me?

Thank you

  • 1

    I made a Windows VM machine use a VPN connection established by the Linux machine. Basically I set up a route on the Windows VM saying that anything for 192.168.10.0 should be redirected to the gateway for 10.10.0.18 (Linux address on VPN). I can post the detailed solution if you want.

  • Please, just do it.

  • 1

    Note that it’s the opposite of what you need, but maybe the steps I’ll show you will help you set up what you need. OK?

  • @Cantoni answers yes. You can also ask in Meta if you think it might be off topic..

1 answer

1

As stated in the comments, my problem was different from the one reported, because in my case, the VPN connection is on the real machine (host) and I need to share with a virtual machine (guest).

I believe that, as stated, this can help to make the requested configuration. The author of the question agreed and asked me to respond.

My environment is so configuarado:

Real Machine (host)

  • Ubuntu 15.04
  • Openvpn
  • Internal network address: 192.168.1.238
  • VPN address: 10.20.0.50

The host connects to the enterprise VPN. The subnetwork of the internal VPN machines (i.e., the enterprise machines) is 192.168.30.0

Virtual Machine (guest room)

  • Windows 7
  • Network configuration mode: Bridge
  • Internal network address: 192.168.1.216

Goal: make Windows 7 (VM) have access to the VPN connection established by Ubuntu (host).

One option is to set the VM network to NAT (Virtualbox default configuration). This makes the VPN work on Windows, however, this does not solve me, since I need this machine to be part of the internal network of my home. In other words, I need her to have an address on the 192.168.1.0 network (internal home network). So it needs to be set up as Bridge, not NAT.

So, to resolve this issue, I took the following steps:

  1. Set up two network interfaces in the VM. The first in Bridge mode, the second in NAT mode.

This setting in Virtualbox will cause Windows to have two network interfaces, one on the 192.168.1.0 network (home) and another on the 10.0.3.0 network (Virtualbox’s own network, not to be confused with the VPN network). For questions, see Virtualbox NAT mode: https://www.virtualbox.org/manual/ch06.html#networkingmodes

Important: The fact of being on the network 10.0.3.0 is what allows access to the Host network and that is why I can drip, from the VM, the host address on the VPN (10.20.0.50).

  1. Create a routing between the VM and the VPN address.

As mentioned above, it is possible to access 10.20.0.50 from the VM. Thus, to finish, just create a route in Windows. Follow the steps:

  • Open Windows prompt as Administrator;
  • Type the following line: route -p add 192.168.30.0 MASK 255.255.255.0 10.20.0.50
  • Ready. Windows machine can now access VPN.

Explanation: the above command adds a row in the Windows routing table specifying that any access to 192.168.30.0 network addresses must be routed to 10.20.0.50. The -p parameter indicates that this route should be persistent, so when the machine is restarted the route will be set automatically.

The scenario of the question

The author has the reverse need, IE, the VPN connection is in the VM and he needs the host to have access to it. The first thing to check is if, from the host, you can drip the VPN IP in guest. If you can, then you can set up a routing on Linux (host), saying that connections to company subnet addresses are routed to that VPN address on the VM. In short, it is the opposite of the above, but the concepts are exactly the same, since it is about routing (layer 3).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.