1

过去,我使用以下代码在 Windows 中通过 Linux 完美地连接到 VPN:

    import win32ras

    hdl, retcode = win32ras.Dial (None, None, (vpn_name, ip, "", username, password, ""), None) #changing 'ip' will connect to that server ip

    win32ras.HangUp (hdl) #This disconnects the connection

所以这在带有 python 的 windows 中工作得很好,但现在我想在 ubuntu 中用 python 来做,我根本不知道该怎么做。我也想做同样的事情,定义一个 VPN 名称并在连接时更改其 IP,并通过用户名/密码输入,如果有任何其他方式,比如直接连接到 VPN 甚至不创建一个,那显然更好。

我现在在互联网上找到解决方案,如果我找到什么会更新。

4

1 回答 1

1

使用 Linux PPTP 客户端怎么样:http: //pptpclient.sourceforge.net/

从 Python 调用它的几个选项:

1)使用子进程将其称为命令行工具:https ://docs.python.org/2/library/subprocess.html

2) 将其构建为库并通过 Cython 调用它:http ://cython.org/

3) 将其构建为 Python 包(为了获得奖励积分,将其提供给其他人!):https ://docs.python.org/2/extending/extending.html

于 2015-01-10T10:31:13.160 回答