Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access database on Windows server through VPN from nodejs running on Linux

I'm kind of lost in my current project. From a linux machine (Ubuntu server), running a code in nodejs I have to connect to a windows server, through VPN, and access a mySQL server running on it.

About the VPN server I only know it's Windows and I can easily connect to it by using the VPN conector on another Windows machine, I do not have access to that machine or know its parameters.

All I have is the IP of both VPN and database server inside that VPN, and username/password for VPN and database as well. Also I know that the VPN uses ms-chap v2.

I'm trying to use openvpn like that:

sudo openvpn --remote vpnIP --dev tun --ifconfig 127.0.0.1 dbIP

This does not show any error message but never request VPN's username/password

And what should I do from nodejs to access the database once VPN is created?

As I've said, I'm very lost on that! Any tip will be welcome!

like image 346
Gustavo Vargas Avatar asked Mar 18 '17 14:03

Gustavo Vargas


2 Answers

Unless something else is specified, a Windows based VPN almost always uses PPTP. You can not connect with OpenVPN. You have to use a PPTP client.

The Ubuntu package is pptp-linux. There is a detailed explanation on how to configure it here.

In a nutshell (I assume you have no GUI on a server), you can create a tunnel with :

pptpsetup --create my_tunnel --server <server_address> --username <username> --password '<password>' --encrypt

Configuration files will be created in /etc/ppp. You can then connect (in debug mode) with:

pon my_tunnel debug dump logfd 2 nodetach

or simply (once it work) :

pon my_tunnel

and stop it with :

poff my_tunnel

If the server is a gateway, you may need to add a route, something like :

ip route add 192.168.1.0/24 dev ppp0
like image 52
bwt Avatar answered Sep 19 '22 16:09

bwt


You may want Network Manager with a plugin network-manager-pptp, also see this wiki https://help.ubuntu.com/community/VPNClient#PPTP

like image 44
fangxing Avatar answered Sep 19 '22 16:09

fangxing