(This is the original question but my eventual solution was too different from how I originally asked the question so I'm posting as a new question.)
I have a VM with three different interfaces: Management (eth0), Production (eth1), and Backup (eth2). Management is for RDP and SSH traffic. Production is for the bulk of traffic. Backup is for communication with backup services, all on the same subnet. Each network is restricted to its own purpose and any traffic that looks like it should be carried by one of the other networks will be dropped (for example,
tcp/22 is dropped on the Production network).
SSH traffic is coming into the server on the Management port but is leaving on the Production interface:
This causes the traffic to be dropped since the packets will be
tcp/22 going out to the production network.
If I change the default route to point to the management gateway the packets go out the correct interface so ssh works but then all production traffic stops working. I can leave the default route pointing at PROD and it will still work as long as I'm connecting on from a machine on the same subnet.
I need the kernel to set the default gateway dependent on what interface the traffic originated on.