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!

Gustavo Vargas
  • 2,497
  • 2
  • 24
  • 32
  • 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. – Hultner Mar 21 '17 at 11:30
  • @Hultner 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. – Gustavo Vargas Mar 21 '17 at 17:20

2 Answers2

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
bwt
  • 17,292
  • 1
  • 42
  • 60
  • 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? – Gustavo Vargas Mar 21 '17 at 20:04
  • 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 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 http://pptpclient.sourceforge.net/routing.phtml#client-to-lan (Client to LAN part). You can also add a default route. – bwt Mar 21 '17 at 20:26
1

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

Fangxing
  • 5,716
  • 2
  • 49
  • 53