Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.