Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a database running on VM?

I got a question here. Seems a little complicated in my mind. Hope I can make myself clear. :)

  1. I have a Win7 system (system A) with a Win7 VM (system B) running on it.
  2. System B is connected to a intranet through VPN to log some realtime data into a local sql server database. Internet connection is disabled by administrator so System B is separated from outside.
  3. Now System A wants to connect to this database and read these realtime data.

Is it possible?

like image 482
Globalhawk Avatar asked Nov 04 '22 00:11

Globalhawk


1 Answers

I don't have any experience with vmware, but assuming you can use any VM, here's a solution for VirtualBox:

  • Setup a network interface on your VM, that's visible to the host system only (reference):

Host-only networking is another networking mode that was added with version 2.2 of VirtualBox. It can be thought of as a hybrid between the bridged and internal networking modes: as with bridged networking, the virtual machines can talk to each other and the host as if they were connected through a physical ethernet switch. Similarly, as with internal networking however, a physical networking interface need not be present, and the virtual machines cannot talk to the world outside the host since they are not connected to a physical networking interface.

  • Configure port forwarding on system B ([external_port] -> [host_over_vpn]:[service_port])

Connect to [system_B_ip_over_provided_interface]:[external_port] as if you were connecting to the database directly.

like image 87
Szymon Jednac Avatar answered Nov 10 '22 17:11

Szymon Jednac