Multiple IP addresses handling by SIP


I have a Asterisk 1.4.4 box with 2 providers and of course 2 ip addresses.
The routing for the packets sent by the box is done based on its source ip
For example:

provider1 has a.a.a.a
provider2 has b.b.b.b

if packet has source ip a.a.a.a it leaves via provider1
if packet has source ip b.b.b.b it leaves via provider2

the default gateway is provider1

so all outgoing connections go via provider 1
but the incoming connections are handled by both providers separately.

Asterisk does not work like i was expecting it to do
If an INVITE comes in via provider2 with dest. ip b.b.b.b Asterisk replies with a packet that has the source ip a.a.a.a, because of that it leaves via provider1 and things don’t work any more.

From what I know Asterisk finds its source address from the routing tables which is now always the correct choice.
It wold be nice if Asterisk would get the reply packet’s source ip from the destination ip of the request packet like all the other apps do.

Does anyone know how to solve this problem or at least a workaround.