Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering if it is possible to route a same packet differently based on which interface it comes from. For example, there are two Ethernet interfaces on a Linux box, eth1 and eht2. for IP packets with same destination and source IP addresses, if the packet comes from eth1, then next hop will be IP-X and if the packet comes from eth2 the next hop will be IP-Y.

share|improve this question

Yes, you can do it exactly like that. However, you probably don't really want to. The problem with these kinds of schemes is that they tend to break traffic in the other direction and as a result, the network doesn't work. What you probably actually want is source-based routing.

Linux permits you to create multiple routing tables. Each one can have its own separate routes and gateway. You can then choose which routing table is used by a packet based on the interface it's received on or the source address. Typically the source address is what you really want. For example, that's the sensible way to connect a single machine to more than one Internet connection.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .