Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you connect to vpn using node.js

Tags:

node.js

vpn

pptp

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

like image 609
montage9 Avatar asked Aug 13 '13 20:08

montage9


1 Answers

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

like image 113
CodeBug Avatar answered Sep 17 '22 21:09

CodeBug