Share VPN connection of virtual machine with real machine

2

I'm having a problem because I started using a few months Ubuntu and now I've recently migrated to Mint .

I'm working with Java Web but for testing I need to access the client database through VPN . Unfortunately the installer of this VPN only exists for Windows and Mac . I already tried to configure it according to certain tutorials but they did not work out.

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

I would like to know if I have to share the VM connection when it uses VPN with the Linux machine to configure my properties file pointing to the ip of the company database.

Because when I go to prompt and I type ipconfig/all it only shows the ip of the bank.

Can anyone help me?

Thank you

    
asked by anonymous 26.05.2015 / 14:51

1 answer

2

As stated in the comments, my problem was different from the one reported, because in my case, the VPN connection is on the host machine and I need to share it with a 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 thus configured:

Real Machine (host)

  • Ubuntu 15.04
  • OpenVpn
  • Address on the internal network: 192.168.1.238
  • VPN Address: 10.20.0.50

The host connects to the company's VPN. The subnet of the internal VPN machines (ie the machines of the company) is 192.168.30.0

Virtual Machine (guest)

  • Windows 7
  • Network configuration mode: Bridge
  • Address on the internal network: 192.168.1.216

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

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

So, to solve this question, I took the following steps:

  • Configure two network interfaces in the VM. The first in Bridge mode, the second in NAT mode.
  • This configuration 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's NAT mode: link

    Important : Being on the 10.0.3.0 network is what allows access to the Host network, which is why I can ping the host's VPN address from the VM (10.20.0.50).

  • Create a routing between the VM and the VPN address.
  • As stated above, you can access the 10.20.0.50 from the VM. In this way, to finish, it was enough to create a route in Windows. Follow the steps below:

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

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

    The question scenario

    The author has the inverse need, ie the VPN connection is in the VM and it needs the host to have access to it. The first thing to check is if, from the host, you can ping the IP of the VPN on the guest. If so, then you can set a routing on Linux (host), saying that connections to the company's subnet addresses are routed to that VPN address in the VM. In short, it is the opposite of the one exposed here, but the concepts are exactly the same, since it is routing (layer 3).

        
    16.08.2015 / 14:29