Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Create a VPN connection for just a host

I want to create a VPN connect with a Python script for just a few Python Sockets. I need to tunnel just the traffic of that Script through a VPN like a Proxy does it.
Is there an API?

I cannot change the setting of the machine because the user may not want to create a VPN which tunnels his traffic.

like image 752
Matt3o12 Avatar asked Jul 27 '13 10:07

Matt3o12


People also ask

Can we create VPN using Python?

Requirements. OpenVPN needs to be installed. The script should run on any Linux distribution with the Python Requests module installed. The user running the script must be able to run sudo commands in order to start openvpn .

How does Python connect to VPN code?

##Quickstart Just type python vpngate.py in your terminal screen and select country and server you want to connect. The connection can be terminated by pressing Ctrl + C . If you want connect vpn server using default options, just type python vpngate.py -y .


1 Answers

What you want is not a VPN, is an IP port forward, a proxy:

http://voorloopnul.com/blog/a-python-proxy-in-less-than-100-lines-of-code/

If need a secure connection between 2 hosts you could use a SSH port forward:

http://www.debianadmin.com/howto-use-ssh-local-and-remote-port-forwarding.html

like image 165
Edorka Avatar answered Oct 16 '22 05:10

Edorka