Linux – Communicating via separate network cards

internetlinuxnetworkingnic

Assume you have a web server with two network cards (and their associated ports), let's call them A and B. The idea is to connect one port (A) to the internet and the other (B) to some isolated network of servers for various computations. This seems to be relatively common, one network exposed to the internet for the actual sending and receiving of information and a private network for secure data storage, administrative control, etc.

How would traffic be directed through one or the other? The only side I've seen to this is the code side, and in all languages I'm familiar with, you initiate communication (TCP, say) by providing a destination address, not an origin address. If you want to talk to a specific machine connected (via switch) to one port or the other, how would you specify which? Moreover, what if you had machines connected via both A and B but some traffic (maybe financial information) would need to be sent through B while other traffic (REST data, for example) would be a better fit for A?

Best Answer

You would probably do this with routing - have one subnet on port A and another subnet on port B. Then the OS will route the packets through the correct interface according to the service it needs to reach.

Related Topic