在 iOS 应用中利用 L2TP 协议实现 VPN

在 iOS 设置中,有使用 IPSec、 IKEv2和 L2TP 创建 VPN 配置的选项。使用苹果公司的网络扩展框架,可以选择仅使用 IPSec 和 IKEv2协议创建 VPN。他们的工作,但问题是,我需要创建一个通过 L2TP 连接,因为这是唯一支持的公司的防火墙。

有一个2014年的问题 具有自定义 VPN 连接的 iOS 应用程序回答:

如果你想在 ios 8中以编程方式连接,你只能使用 IPSec 或 IKEv2协议。L2TP 和 PPTP 协议对于苹果是私有的。在应用程序中不可能使用 L2TP 和 PPTP API。目前只有苹果公司在使用这些 API。

有没有办法从 iOS 应用程序(Swift)创建 L2TP VPN 连接?

4578 次浏览

You can make use of every proxy app available on Android playstore. Basically youre iOS device will make use of the hostpot from android phone. Remember youre android phone must be connected to L2TP VPN. Every proxy will put all the connection of VPN shared to iOS device.

iOS device in settings we need to add ip and port. You will now be connected to VPN on iOS.

You can try hosting an l2tp server on your mac and connect another device remotely to the server using the settings->network->vpn->l2tp and provide the settings. I haven't tried it personally. On the iPhone General->VPN Management->L2tp can be used.

Is it possible that the company this is for has some sort of internal framework or package you can use for their VPN authentication within your app?

The Personal VPN feature that allows using built-in protocols doesn't support unencrypted protocols, presumably for security reasons:

Personal VPN only supports recommended VPN protocols; it doesn’t support legacy VPN protocols, like PPTP and L2TP.

However, that's not the only way to implement a VPN app. You can also create a Packet Tunnel Provider to tunnel layer 3 packets yourself, or an App Proxy Provider for TCP and UDP connections. A packet tunnel provider would allow using your own L2TP implementation.

This might be solving the wrong problem, though. If this is for a specific company, why not use MDM instead of a custom app? MDM does support L2TP.

It is not possible to create a L2TP VPN connection from an iOS application. Only Apple is currently using the L2TP and PPTP APIs.