2 gateways with Asterisk

Hi guys, I have two internet connections on my LAN (one via gateway and the other at gate Currently my * box is using as the default gateway and it works fine. To increase my call capacity, I’d like to allow it to receive calls inbound via the x.254 gateway. How would I open this up?

I’m looking for * to send outbound calls via but accept INCOMING sip calls from this gateway and also (and carry them on whichever gateway initiated them).

(I tried pointing one of my inbound PSTN numbers to the IP of the x.254 gateway and it worked so far as triggering the call, but the actual call stream went out via the default gateway). I have ports set on both gateways pointing to the IP of the * box.

Many thanks in advance. :bulb:

If the gateways are simple routers, the machine on which Asterisk is running has no information as to which one was used.

If any source can use either gateway, you will need to install a SIP proxy on each gateway.

Simply, I want to a point some of my incoming PSTN numbers to come in via gateway1 and the rest to come in via gateway2.
Both gateways have static IPs and it’s a matter of just giving them to my trunk provider, which is all fine but when I tried pointing a number to gateway2’s IP and called that number, the call rang and was answerable fine, but on checking the router, the call was actually traversing gateway1 even though it was initiated via gateway2.

Thank you.

Do any of you guys have any more thoughts on this, I am considering a second * box interconnected to the existing box so each will have it’s own default gateway to get this working, but obviously at the price of double power consumption!


One way to do this would be to use a link agregator\balancer that available in some routers or look at F5’s BigIP or Barracuda’s Link Balancer.

If I am reading this correctly, the SIP messaging is coming over the second link properly, but the RTP stream is always going out your default gateway link… is that correct?

If that is the case, then you will need to establish some static routes for the RTP destinations you want to send over the second WAN connection. Remember that in SIP, the messaging and media are totally separate, so even though you have a specific path for the messaging, your media will go whatever route the OS decides is best… in this case the default gateway will win.

That is exactly what is happening, and I figured it may need some manual routing - but I’ve never dealt this far into the setup before, could you point me to some pages on how to do what you mentioned, or post an example for me to modify? Thanks in advance.

the changes would need to be at the OS level. The first question you need to answer is:

Is the RTP source a predictable destination? For Example, if a SIP session is set up over WAN 2, will the RTP destination always be the same IP or subnet? If the answer is yes, we can move forward, if the answer is no, you have a much more complicated problem to solve.

Yes the source would be the same IP each call/session, but the only problem I can think of may be that gateway1 will also be accepting calls from the same source, but I can fix it so each gateway receives calls from two different sources, for routing purposes.

His problem is that, from the point of view of the OS, the destination is always the same, his service provider. Only Asterisk knows which SIP connection it relates to. If you throw in Re-invites, there is really no way for the OS to work it out.

He really needs to NAT and arrange that different calls come in via different NAT interfaces, to stand any chance.