[OpenSIPS-Users] Outbound gateway selection

Alejandro Recarey alexrecarey at gmail.com
Thu May 6 02:38:08 CEST 2010


I am using OpenSIPS to load balance incoming calls between my asterisk
boxes, with great results! The LB module is perfect for this.

I am currently configuring OpenSIPS to also act as an outbound proxy
to my asterisk boxes. This is because some VoIP providers want you to
send them all calls from a single IP address.

However, I have a problem with the setup. The authentification of the
incoming calls is done with the "permission.so" module and works
perfectly. However, because the destination URI always has the IP
address of my OpenSIPS box, I have no way to distinguish what carrier
(IP address) I should actually be sending the call to.

The only solution I have found so far is to add an internal prefix
(for example 1# for carrier 1 with IP X, 2# for carrier 2 with IP Y
etc), this way I can match the uri like

if(uri=~"^sip:1#[0-9]*+@"){
  rewritehostport("x.x.x.x");
  route(1)
}

if(uri=~"^sip:2#[0-9]*+@"){
  rewritehostport("y.y.y.y");
  route(1)
}


However, I have to strip this prefix when forwarding the invite to my
carrier, because my carrier will not accept the prefix. This is easily
done with the dialplan module, but I also have to _add it back_ when
forwarding RE-INVITES, TRYING, ACK or other messages that come from my
carrier, so that asterisk does not get confused when to: or uri tags
do not match. This seems like an ugly solution, or maybe I don't know
how to set it up?

What is the best way to setup this scenario?

Thank you for your help!



More information about the Users mailing list