Implementing VPN with L2TP protocol in iOS app
Asked Answered
M

5

93

In iOS settings, there are options to create a VPN configuration using IPSec, IKEv2, and L2TP. Using the NetworkExtension framework from Apple there's an option to create VPN using IPSec and IKEv2 protocols only. They do work but problem is that I need to create a connection via L2TP since that's only supported by the company's firewall.

There's a question iOS app with custom VPN connect from 2014 and it's answered with:

If you want to connect programmatically in ios 8 you can use only IPSec or IKEv2 protocols. L2TP and PPTP protocols are private for apple. It is not possible to use L2TP and PPTP APIs in your applications. Only Apple is currently using these APIs.

Is there any way to create a L2TP VPN connection from an iOS application (Swift)?

Moorwort answered 24/1, 2017 at 10:8 Comment(8)
@StanislavMayorov: It's possible to create a .mobileconfig profile which uses L2TP.Mckim
@l'L'l I'm afraid that the app could be rejected in apple store. Apple guidelines say that Apps offering VPN services must utilize the NEVPNManager APIGist
@StanislavMayorov: I suspected that would be the case unfortunately; It's possible Apple might've removed the ability to use L2TP anyway in the latest iOS even with a .mobileconfig, although I haven't tried it.Mckim
@l'L'l I have tested in iOS 11.3 that it's still possible to configure L2TP using .mobileconfig. But I think it's kind of workaround to use .mobileconfig programmatically for vpn.Gist
@StanislavMayorov Here is a nice thread on Apple forum about this problem: forums.developer.apple.com/thread/70696 Eskimo has nice response with recommendations.Cowardice
yes it is possible to use .mobileconfig to install L2TP configuration, I tried it and succeeded but we can just install configuration not control it, means we can not on or off this VPN through ur applicationIronsides
if some one have some solution then please share itIronsides
That answer certainly refers to the Apple API, not to the protocol!Contortion
P
2

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

Poeticize answered 1/9, 2022 at 21:47 Comment(0)
R
1

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.

Redouble answered 29/7, 2022 at 1:54 Comment(0)
C
0

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?

Cambium answered 3/6, 2022 at 4:11 Comment(0)
C
-1

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.

Cheeseburger answered 4/5, 2022 at 8:39 Comment(1)
As stated in the question, iOS natively supports connecting to an L2TP VPN. The issue is whether this can be done programmatically from an app.Redouble
B
-1

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.

Billhead answered 30/5, 2022 at 2:28 Comment(1)
The issue isn't about whether iOS can connect to an L2TP VPN at all, it's about whether an app can do it programmatically as is possible for IPsec and IKEv2.Redouble

© 2022 - 2024 — McMap. All rights reserved.