简体   繁体   English

通过VPN从Linux上运行的nodejs访问Windows服务器上的数据库

[英]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. 从linux机器(Ubuntu服务器),在nodejs中运行代码,我必须通过VPN连接到Windows服务器,并访问在其上运行的mySQL服务器。

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. 关于VPN服务器我只知道它是Windows,我可以通过在另一台Windows机器上使用VPN连接器轻松连接到它,我无法访问该机器或了解其参数。

All I have is the IP of both VPN and database server inside that VPN, and username/password for VPN and database as well. 我所拥有的只是该VPN内部的VPN和数据库服务器的IP,以及VPN和数据库的用户名/密码。 Also I know that the VPN uses ms-chap v2 . 我也知道VPN使用ms-chap v2

I'm trying to use openvpn like that: 我正在尝试使用openvpn:

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 这不显示任何错误消息,但从不请求VPN的用户名/密码

And what should I do from nodejs to access the database once VPN is created? 创建VPN后,我应该怎么做nodejs来访问数据库?

As I've said, I'm very lost on that! 正如我所说,我很失落! Any tip will be welcome! 任何小费都将受到欢迎!

Unless something else is specified, a Windows based VPN almost always uses PPTP . 除非指定其他内容,否则基于Windows的VPN几乎总是使用PPTP You can not connect with OpenVPN. 您无法与OpenVPN连接。 You have to use a PPTP client. 您必须使用PPTP客户端。

The Ubuntu package is pptp-linux . Ubuntu包是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 : 简而言之(我假设您在服务器上没有GUI),您可以使用以下命令创建隧道:

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

Configuration files will be created in /etc/ppp . 配置文件将在/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

您可能希望网络管理器使用插件network-manager-pptp ,也可以参见此wiki https://help.ubuntu.com/community/VPNClient#PPTP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM