I have found plenty of hints on the web to create permanent static routes to a particular gateway IP address, but I unfortunately I did not find a way to create a permanent static route to an interface.
I have a VPN connection which itself offers access to further private networks. The VPN, when connected, is available on the virtual interface utun1.
I have no problems to gain access to the further private networks when manually adding a route:
route -nv add 192.168.0.0/16 -interface utun1
However, this command is not persistent. Clearly, I could permanently add static routes, but the following command does not allow me to specify the interface.
Usage: networksetup -setadditionalroutes <networkservice> [ <dest> <mask> <gateway> ]* Set additional IPv4 routes associated with <networkservice> by specifying one or more [ <dest> <mask> <gateway> ] tuples. Remove additional routes by specifying no arguments. If <gateway> is "", the route is direct to the interface
When specifying the gateway as "", I may only address my en0 interface, but not the unet1 interface.
Furthermore, this route should only be created once the VPN connection is enabled that makes the interface unet1 available.
It would be great if someone could give me some guidance as how to further go on.
Best regards, Peter