In Linux, routing is performed by looking at the destination address
only, so a packet will follow whichever route can be used to reach the
packet's destination, with no regard to the source address.
The behaviour you want requires choosing a route depending not only on
the destination address, but also on the source address — this is
sometimes called source-sensitive routing or SADR
(source-address dependent routing). The most portable way of implementing
source-sensitive routing under Linux is to define routing rules across
multiple routing tables using the
ip rule and
... table ... commands.
This is described in detail in Section 4 of the Linux Advanced Routing and
Traffic Control HOWTO