Packet Tunnel Provider Guide

Hi, I want to develop an enterprise VPN app with a custom protocol. I'm following the documentation but I have no clue how to start, is there any guide I can follow?

Answered by DTS Engineer in 827099022
Written by mewancdot in 826867022
Ohhh.

Oh, I shoulda mentioned that Network Extension Resources has links to the docs, samples, and so on that do exist. I expect there’s a bunch of third-party resources as well.

Written by mewancdot in 826867022
Currently, only for ios.

OK. That simplifies things because there’s only one deployment path. See TN3134 Network Extension provider deployment.

Getting started with a packet tunnel provider is reasonably straightforward these days. There’s an Xcode target template under iOS > Network Extension. It takes care of all the packaging concerns. You then fill in startTunnel(options:completionHandler:) method override to:

  1. Start your tunnel. You can use normally networking APIs for this, so either Network framework or BSD Sockets. See TN3151 Choosing the right networking API for more on that.

  2. Once the tunnel is up, apply the settings for that tunnel by calling the setTunnelNetworkSettings(_:completionHandler:) method.

  3. When that’s done, call the completion handler that was passed to your startTunnel(options:completionHandler:) method. This tells the system that the tunnel’s interface is up and functioning.

  4. Finally, read outgoing packets from, and write incoming packets to, the tunnel interface using the self.packetFlow property.

The most complicated part of this is the tunnel network settings, and there’s specific advice on that front in Routing your VPN network traffic.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Written by mewancdot in 775286021
is there any guide I can follow?

Not really )-:

What platform are you targeting?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Not really )-:

Ohhh.

What platform are you targeting?

Currently, only for ios.

Written by mewancdot in 826867022
Ohhh.

Oh, I shoulda mentioned that Network Extension Resources has links to the docs, samples, and so on that do exist. I expect there’s a bunch of third-party resources as well.

Written by mewancdot in 826867022
Currently, only for ios.

OK. That simplifies things because there’s only one deployment path. See TN3134 Network Extension provider deployment.

Getting started with a packet tunnel provider is reasonably straightforward these days. There’s an Xcode target template under iOS > Network Extension. It takes care of all the packaging concerns. You then fill in startTunnel(options:completionHandler:) method override to:

  1. Start your tunnel. You can use normally networking APIs for this, so either Network framework or BSD Sockets. See TN3151 Choosing the right networking API for more on that.

  2. Once the tunnel is up, apply the settings for that tunnel by calling the setTunnelNetworkSettings(_:completionHandler:) method.

  3. When that’s done, call the completion handler that was passed to your startTunnel(options:completionHandler:) method. This tells the system that the tunnel’s interface is up and functioning.

  4. Finally, read outgoing packets from, and write incoming packets to, the tunnel interface using the self.packetFlow property.

The most complicated part of this is the tunnel network settings, and there’s specific advice on that front in Routing your VPN network traffic.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Packet Tunnel Provider Guide
 
 
Q