I have a requirement from an upstream provider that is providing multiple termination only gateways to me. The requirement is that I have to have a unique source ip address for each gateway that I will be terminating calls to. I would like to use only one kamailio system bound to multiple ip addresses to meet this requirement. I have my LCR built with the various routes to the gateways. I have identified the function force_send_socket([proto:]address[:port]) which seems like it can be used to meet this functional requirement. I am a little confused how to implement this function with LCR.
My basic requirement is that if upstream gateway ip address == 1.2.3.4 then originate and maintain the dialog from my source ip 4.3.2.1 else if gateway ip == 6.7.8.9 then originate and maintain dialog using soure ip 9.8.7.6, else if ... N upstream gateways
Is force_send_socket([proto:]address[:port]) the function that I need to be trying to use to meet this requirement? Is there a simpler method that can be used instead?
Any help will be appreciated.
Stagg
Stagg Shelton writes:
My basic requirement is that if upstream gateway ip address == 1.2.3.4 then originate and maintain the dialog from my source ip 4.3.2.1 else if gateway ip == 6.7.8.9 then originate and maintain dialog using soure ip 9.8.7.6, else if ... N upstream gateways
after you have called next_gw(), you can write a switch statement on request uri host or on gw's flags that sets the desired source address.
looks like force_send_socket does not allow a pv argument, which could allow a more dynamic implementation. you could open a feature request on it.
-- juha
Hi Juha,
Would I use the force_send_socket to set the source address inside the switch, or is there some other method that should be used.
Thanks Stagg
On Jun 19, 2009, at 2:03 PM, Juha Heinanen wrote:
Stagg Shelton writes:
My basic requirement is that if upstream gateway ip address == 1.2.3.4 then originate and maintain the dialog from my source ip 4.3.2.1 else if gateway ip == 6.7.8.9 then originate and maintain dialog using soure ip 9.8.7.6, else if ... N upstream gateways
after you have called next_gw(), you can write a switch statement on request uri host or on gw's flags that sets the desired source address.
looks like force_send_socket does not allow a pv argument, which could allow a more dynamic implementation. you could open a feature request on it.
-- juha
Thanks Juha,
I sat down yesterday and got the configuration working on a development system. For the benefit of anyone else doing something similar here is the config that I ended up with.
Where A.B.C.D is the IP part of the ruri returned by next_gw, and E.F.G.H, I.J.K.L are IPs of local sockets that my system is listening on. I also have the if(uri=~"sip... statement in a branch set to handle the call to next_gw from the failure route if called.
if(!load_gws()) { xlog("L_INFO", "[ROUTE-X] Unable To Find Gateway "); route(4); exit; }
if (next_gw()) { # prepare for lcr failover t_on_failure("2"); if(uri=~"sip:.*[@]A.B.C.D+.*") { force_send_socket(udp:E.F.G.H:5060); } else { force_send_socket(udp:I.J.K.L:5060); };
Thank you for your responses.
Stagg
On Jun 20, 2009, at 2:01 PM, Juha Heinanen wrote:
Stagg Shelton writes:
Would I use the force_send_socket to set the source address inside the switch, or is there some other method that should be used.
use force_send_socket,
-- juha