I have host A with two NICs. One NIC(1) is at 192.168.0.36, the other NIC(2) is directly on the internet. The default route for host A is the router on the internet (so traffic is routed through NIC(2). Host B is at 192.168.0.10 and is a firewall connected to the internet, on a completely different subnet from host A, NIC(2). Host A and B have no problems connecting to each other over the 192.168.0.0 network.
I have a web server running on host A, bound to both NICs. I can connect to the server over the internet using the IP address for host A, NIC(2). The firewall on host B is configured to forward port 80 to 192.168.0.36. If I try to bring up the web page by connecting to the external IP address on that firewall, though, it never comes up. Packets obviously reach host A, though, as tcpdump on host A shows:
07:50:16.582844 IP some-remote-machine-on-the-internet-that-I-am-testing-from.34458 > 192.168.0.36.www: S 1006697601:1006697601(0) win 14600 <mss 1460,sackOK,timestamp 1027543073 0,nop,wscale 4>
Now, if I change the route for some-remote-machine-on-the-internet-that-I-am-testing-from to 192.168.0.10, the page will come up. If I change the default route for all network traffic to 192.168.0.10, anyone connecting to the external IP address on the firewall will get the web page. But then, of course, any attempted connection to the IP address on NIC(2) will fail.
Is it possible to have host A route data through a specific route/nic depending on the NIC the connection originates from?