Routing packets back from incoming interface

There is a known issue (it is a design issue) with Linux networking stack. If you have multiple interface to connect wan side, for example ppp0 is dialup, eth0 leased line, wlan0 wireless etc. normally you have 3 default routing entry too.

In this case, if a packet arrives from ppp0 interface, their reply packets sent from default router and it can be wlan0 interface. So, connection can’t be established.

To solve this problem, reply packets must be return back with same interface. If packet arrives from ppp0 interface, their replies also must sent from ppp0 interface too.

To do this, we’ll use iproute package. First of all, a routing table entry must be created:

echo 101 Tppp0 >> /etc/iproute2/rt_tables

Second, we have to say ppp0 packets routed by the Tppp0 table:

ip rule add dev ppp0 table Tppp0

And we have to say that table Tppp0's default router is the default router of ppp0 interface:

ip route add default dev ppp0 table Tppp0

Last, we can flush routing cache:

ip route flush cache

You can repeat above steps for other interfaces too. If so, you have to give a uniq id between 0-255 when creating new table entries in rt_tables file.

Please note that, this is most simple solution and you can make too different / complex setup for different policy routing needs with iproute.