Is it possible to determine ownership of outgoing connections and route them to different interfaces?

I'm trying to build something wherein I can redirect all traffic from a given application to a specified network interface. As an example use case, because I'm stuck with DSL for the time being, I don't want to saturate my line uploading every day things like dropbox or whatnot, so I want to be able to say, all traffic from dropbox should go through the wifi/personal hotspot. I can do this somewhat with squidproxy and specifying each application to go through that proxy -- but that relies on the app even allowing that kind of configuration and it's more work than I think it needs to be.

As an example of the same concept but for audio, see SoundSource by https://rogueamoeba.com/

With soundsource you can direct audio per application to any interface. I want to do the same, but for network traffic. Bonus I can get granular enough to direct outgoing and incoming to different devices on the same app.

But this is an area of systems programming I always felt the least accessible and I'm not really sure where to start reading.

First, I guess I should ask, is this even possible with macos/darwin at this time? I know in linux I could just namespace each application, but as far as I know, macos lacks that kind of functionality.

Cheers

I'm trying to build something wherein I can redirect all traffic from a given application to a specified network interface.

Redirecting traffic based on interface is not recommended. If you want to create an proxy provider and redirect the traffic to a specific server, then that would be a recommended path.

In regards to trying to identify the source of the traffic, this can be done in some cases if the NEFlow provides the sourceAppAuditToken. This token can be used with SecCodeCopyGuestWithAttributes to further drill down and get signature information from the originating process.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Is it possible to determine ownership of outgoing connections and route them to different interfaces?
 
 
Q