Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send all traffic over VPN connection Swift

Tags:

I am creating an application to connect to a VPN server. I have worked out how to do this, but need to be able to send all traffic over the connection. Is there any code which can do this? So far I have tried:

let manager: NEVPNManager = NEVPNManager.sharedManager()
var p = NEVPNProtocolIPSec()
manager.`protocol` = p

let pw = ""

p.username = ""
p.passwordReference = pw.dataUsingEncoding(NSUTF8StringEncoding)
p.serverAddress = ""
p.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
//p.sharedSecretReference = getPasscodeNSData("vpnSharedSecret")
p.useExtendedAuthentication = true
p.disconnectOnSleep = false
like image 334
Calan54 Avatar asked Jun 21 '15 06:06

Calan54


1 Answers

From Apple:

This is the default routing method. The IP routes are specified by the Packet Tunnel Provider extension at the time that the VPN tunnel is fully established. See NETunnelProvider for more details.

This is something the is specified from the Server end typically, l2tp does allow the user to toggle this setting. For that, take a look at routingMethod part of the NETunnelProvider. Scroll down to the Routing Network Data to the VPN section for the information you are looking for.

like image 68
Cripto Avatar answered Sep 18 '22 05:09

Cripto