How do you connect to vpn using node.js
Asked Answered
W

1

13

I am a newbie to node.js and looking for some example code or pointers on connecting through PPTP to a private virtual ip address using VPN connection. I have a node.js server running on aws that currently uses udp to connect to a public ip address. However, this needs to be changed to tunnel into the private vpn.

I have the uid,pwd and apn for the vpn. What are the steps I would need to take to tunnel in, and then connect to the private ip?

Appreciate any tips you might have.

Thanks M

Wiburg answered 13/8, 2013 at 20:3 Comment(0)
R
3

this is too old a question but for this, it has already several answers in StackOverflow, in that one of the best and I used methods is using the node-openvpn package.

first thing first we need to install the package npm install node-openvpn

at your index.js or server.js use below code

const openvpnmanager = require('node-openvpn');

const opts = {
   host: '127.0.0.1', // normally '127.0.0.1', will default to if undefined
   port: 1337, //port openvpn management console
};

const auth = {
   user: 'vpnUserName',
   pass: 'vpnPassword',
 };
 const openvpn = openvpnmanager.connect(opts)
 
  openvpn.on('connected', () => {
    openvpnmanager.authorize(auth);
   });

here you can read more about the node-openvpn

Rhodos answered 15/5, 2021 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.