Python 仅为主机创建 VPN 连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17896516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 09:25:41  来源:igfitidea点击:

Python Create a VPN connection for just a host

pythonsocketsconnectvpn

提问by Matt3o12

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?

我想为几个 Python 套接字创建一个带有 Python 脚本的 VPN 连接。我只需要像代理那样通过 VPN 传输该脚本的流量。
有API吗?

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

我无法更改机器的设置,因为用户可能不想创建一个 VPN 来传输他的流量。

回答by Edorka

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

你想要的不是VPN,是IP端口转发,代理:

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

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:

如果需要 2 台主机之间的安全连接,您可以使用 SSH 端口转发:

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

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