How to bind a connection to specific Interface/utun?

I am creating a network connection with NWConnection class.

let serverURL = URL(string: "ws://example.com")!
let connection =  NWConnection(to: .url(serverURL)) , using: parameters!)
connection?.start(queue: .main)

let suppose we have three interface a system.

  • en0
  • utun0
  • utun1

By default traffic for this connection will tunnel through en0

I wants that traffic for this connection should tunnel through utun1

how we can do this?

Thanks-:

The NWParameters object you use to create the connection has requiredInterfaceType, requiredInterface, prohibitedInterfaceTypes, and prohibitedInterfaces properties.

Share and Enjoy

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

How to bind a connection to specific Interface/utun?
 
 
Q