I have a Mac with two network interfaces, connected to different networks. For the sake of argument, let's say one is connected to a private network and the other to the Internet.
I understand that I can use the Networks system preference pane to place the Internet interface higher in the "service order" than the private network and that, by doing so, its "Router" will become the system's default gateway (and the other interface's "Router" is ignored).
However, this obviously results in all traffic being routed over the Internet (except the specific subnet of the private network to which the machine is directly connected). I want to override this behaviour for the entire private network, routing all private traffic via the appropriate interface.
What is the "Apple Way" of accomplishing this? Merely executing
sudo route add ... only creates the route temporarily, whereas I want to associate it with the interface in some permanent way (i.e. that will survive the interface changing state, or the system rebooting).
I presume that the solution will involve launchd invoking a script after the interface has come up… but how?!