Network Extension + BSD Sockets

I've implemented a custom VPN system extension for macOS (Packet Tunnel Provider). I created a tunnel, and I have a VPN connection, with the default (IPv4) routes.

My question is about sending traffic which was originated at the extension, via the tunnel. Is it possible to create a BSD socket at the extension, and bind it to a specific interface, so the traffic (that was created from the extension) for this socket will be routed via the tunnel?

Replies

Is it possible to create a BSD socket at the extension, and bind it to a specific interface, so the traffic (that was created from the extension) for this socket will be routed via the tunnel?

While this may be technically possible, it is recommended to use one of the in-provider networking classes such as NWTCPConnection or NWUDPSession. The provider should be able to hand one of these off to you in your extension.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com