<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEPacketTunnelProvider/startTunnel(options:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEPacketTunnelProvider(im)startTunnelWithOptions:completionHandler:"
  },
  "title" : "startTunnel(options:completionHandler:)"
}
-->

# startTunnel(options:completionHandler:)

Start the network tunnel.

```
func startTunnel(options: [String : NSObject]? = nil, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`options`

A dictionary passed by the app that requested that the tunnel be started. If the starting app did not specify a dictionary of options then this parameter will be nil. If the tunnel was started via Connect On Demand, then this parameter will be nil.

`completionHandler`

A block that must be executed when the tunnel is fully established, or when the tunnel cannot be started due to an error. If the tunnel was successfully established, then the error parameter must be set to nil. If an error occurred, the error parameter passed to this block must be set to a non-nil <doc://com.apple.documentation/documentation/Foundation/NSError> object.

## Discussion

This method is called by the system to start the network tunnel.

`NEPacketTunnelProvider` subclasses must override this method.

When the Packet Tunnel Provider executes the completionHandler block with a nil error parameter, it signals to the system that it is ready to begin handling network data. Therefore, the Packet Tunnel Provider should call [`setTunnelNetworkSettings(_:completionHandler:)`](/documentation/NetworkExtension/NETunnelProvider/setTunnelNetworkSettings(_:completionHandler:)) and wait for it to complete before executing the completionHandler block.

The domain and code of the <doc://com.apple.documentation/documentation/Foundation/NSError> object passed to the `completionHandler` block are defined by the Packet Tunnel Provider.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)