Question: How do I launch a program while ensuring that it's network access is bound via a specific network interface?
Case: I want to access two distinct machines with the same IP (192.168.1.1), but accessible via two different network interfaces (eth1 and eth2).
Example:
net-bind -D eth1 -exec {Program 192.168.1.1}
net-bind -D eth2 -exec {Program 192.168.1.1}
The above is an approximation of what I'd like, inspired by the hardware binding done via primusrun and optirun.
Challenge: As suggested in a related thread, the interfaces used are not chosen by the program, but rather by the kernel (Hence the pre-binding syntax in the above example).
Some related solutions I've found, which are unsatisfactory are based on binding network interfaces via user-specific network blacklisting; i.e. running the process as a user which can only access a single specific network interface.