Specifying network device used by software (or port) (in Terminal) Is it possible to specify which network device should be used when running something in the Terminal? Like

$ rails [only communicate through deviceA]


Not just app, but instance specific, so different instances of rails could use different network devices. Alternately, could it be done by port? So localhost:3000 would use deviceA, while localhost:4000 would use deviceB, etc.
Could you just create a local web proxy to run it through? You could create one using
something like this command in the terminal: 

networksetup -setwebproxy "Network Service 1 Name" proxy2.domain.com 3000