Access database on Windows server through VPN from nodejs running on Linux
Asked Answered
B

2

6

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!

Booby answered 18/3, 2017 at 14:30 Comment(2)
Is the vpn running openvpn as the server software? Which Linux distribution are you using? MS-CHAP in a Windows is commonly used with PPTP-based VPN-servers ( a protocol I strongly advise against), if this is the case you have to use a pptp-client.Blackwood
@Blackwood I have edited my question. It's a Ubuntu server 16.04. I do not have any information about the VPN server, but the IP and username/passwd. Iĺl take a look to this pptp-client. Never heard about it before.Booby
T
3

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
Toomey answered 21/3, 2017 at 18:26 Comment(2)
This looks promissing, but I can't test it right now. The gateway you refer to is my linux box or the Windows server? But there is an open point: Once the connection is open how do I make my local client to talk to an IP inside the vpn?Booby
The connection allows you to talk to the (Windows) server. If you want to talk to machines on the remote network, you have to add a route. It basically says "to talk to a machine on <some_network> send the data through the tunnel". In the example the remote network is 192.168.1.0/24, the local network must be something else. This is described pptpclient.sourceforge.net/routing.phtml#client-to-lan (Client to LAN part). You can also add a default route.Toomey
I
1

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

Inocenciainoculable answered 23/3, 2017 at 1:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.