How can I programatically create and dial a VPN connection on iOS? - ios

I've recently noticed that some iOS applications, such as the Astrill VPN Client, are able to create and dial VPN connections. In this specific case they seem to be Cisco IPSEC connections. I have not been able to locate any official Apple documentation on how to do this. Can anyone please tell me how this is possible?
Please note that I know how to configure VPN connections manually. The reason I want my application to do it is to provide an idiot proof and streamlined process for customers.

These iOS apps achieve this by installing a VPN dialling profile that contains a VPN On Demand setting for a specific network and then simply try to connect to an address on that network, which prompts iOS to establish the VPN connection.
VPN On Demand can only be enabled for the IPSec (Cisco) connection type. You can create a dialling profile to do this using the iPhone Configuration Utility to see how it works.

Related

How to setup Packet Tunnel Provider with device-internal VPN

I'm trying to build an iOS app that lists all requests that are made from the device, like Charles Proxy does. Much like Charles, my idea has been to create a Packet Tunnel Provider and have it setup a local VPN connection without an external VPN server. The traffic would then be internally routed to the packet tunnel, without requiring an external VPN server.
Since Charles Proxy does so, I know that it is technically possible, but I can't find any information about how to setup a tunnel with an internal VPN connection, instead of using a "real" external VPN server. The only resource people refers to is the SimpleTunnel Apple sample project, which is a couple years old and written in Swift 3.
I have downloaded the SimpleTunnel sample code project, created the correct entitlements and can now run the project and create a VPN configuration that gets listed under Settings, but I just can't connect the VPN tunnel. I have tried changing the server address to 127.1.0.0 and to use IKEv2, but without success. I have also downloaded the source code at https://github.com/lxdcn/NEPacketTunnelVPNDemo but didn't get it to work either.
Does anyone know how to setup an internal VPN server with NetworkExtensions and have the tunnel use that connection?

Implementing VPN with L2TP protocol in iOS app

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)?
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.
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?
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 to to communicate an iOS app communicate over the USB port to a Windows computer?

I have an iOS application with a tableview which I would like to send text strings via USB to my Windows computer indicating which cell was selected by the user.Anyone have experience with this type of interface?
I've written a blog post detailing how to achieve this here.
http://thecodewash.blogspot.com/2017/05/communicating-with-your-ios-app-over.html
To answer your question (so this answer isn't just a link), yes it definitely is possible to achieve this utilizing the USB Multiplexing Daemon (usbmuxd) program that is usually installed as part of iTunes. This program can create a socket connection to your iOS device through the USB cable, and allow you to communicate via that socket connection like you would any other socket. The link goes into much more detail.
Hope this helps!
(In short) Yes, you can communicate with ios application via normal socket communication by using ITunes which acts like proxy. In this model your ios app acts like server listening for connection. Windows app must connect to iTunes on port 27015 and estabilish connection to specific port (used by ios app) on connected via usb device. This is done by using a special MUX protocol described here

Accessing remotely my web service

I have implemented a web service on my mac and I am able to access its functionalities through the url "http://localhost:8080/ServiceApp-war/resources/".
As I got satisfying results that I could see in the iPhone simulator in Xcode, I decided to connect my iPhone and test on it. But for this to work I think I need to change the "localhost" in my URL to the IP address of my mac.
I tried to replace it with my public IP address and I got a "could not connect to the server" error on my console. I also tried to replace "localhost" with the IP address I found in System Preferences-->Network-->Wi-Fi and I could see that it was working on the simulator but still nothing when I connect my iPhone and run the application on it.
Please provide a solution for accessing my web service remotely.
Thank you.
Create hotspot from your mac, connect to it with your iPhone and try again.
<lame solution>
Try some service for temporary domain, it will make your computer accessible from anywhere.
How do you "connect" your iPhone? USB connection does not create a network. Well, it does create if you turn on Personal Hotspot on your iPhone (maybe in some other cases, dunno). But the most simple way is to connect Mac and iPhone to the same WiFi network.
Once connected, you can use any of "ping" apps available on App Store. Just look for "ping" (some kind of "network reachability test" or so). You can check if your Mac is really reachable on the network.
If it's not reachable, check your network settings on both devices: do they belong to the same subnet, do they use the same gateway, etc.
If your Mac is reachable with ping, then you should deal with your web service. I setup the web server (which is already distributed within OS X): it already has all the settings to allow other devices to connect. But your web service may require some additional setup. It's two basic things: it should bind to your IP address (please check http://YOUR.IP:8080/ServiceApp-war/resources/ from your Mac!) and second, accept incoming connections from other agents, you should find it somewhere in its settings.
Ngrok was the perfect solution I was looking for.
https://ngrok.com
You could also try finch, which is similar to ngrok. It has a nice friendly GUI. https://meetfinch.com

Peer to peer via ip address for iOS

I have ip addresses of two different iOS Devices which are connected to Internet. Now, I want to establish a peer-to-peer connection between them.
I had done this locally with Wifi and it worked properly. But I dont know how to establish this connection with an IP address. I want that I can connect them from anywhere, so I need to connect via Ip address. Also, is this possible without developing any server? Please help. Thanks.
I couldn't find any exact solution for this problem but one approach could be you can have two ios devices connected with a network having same public IP.
So indirectly both ios devices will be connected to the same network.
What you had done with wifi is probably an Ad-Hoc connection. Ad-Hoc is when you connect 2 wifi devices without any Access Point in the between.
You do not have to do that on the Internet, your devices are already connected to a network. What you need to do is to find out what their IP addresses are and provide them to eachother.
In case your iOS devices are NATed behind a router, you must forward the port which you want to use from the router to the iOS device.
Here are guides for port forwarding for all the existing routers: http://portforward.com/

Resources