Thank you very much for your reply Barry.
Can you explain us yours ip 10.5.75. and 10.5.76. ?
Seems your asterisks have two interfaces, one private and one public?
In my infrastructure I have:
SIP client -> Kamailio ---> Asterisk 01
---> Asterisk 02
...
---> Asterisk N
Only Kamailio has a public IP address.
In the REGFWD route you send all the registrations to ALL the Asterisks?
If so, why?
I'm trying to achieve something like:
SIP clientA ---> REG ---> Kamailio Is Asterisk01 alive? Yes --> REG ---> Asterisk 01
NO --> Choose next one
---> Asterisk 02
...
---> Asterisk N
---> Asterisk 01
SIP clientB ---> REG ---> Kamailio Is Asterisl02 alive? Yes --> REG ---> Asterisk 02
NO --> Choose next one
---> Asterisk 03
...
---> Asterisk N
and so on, with a round robin algorithm.
When Sip ClientA want to call Sip ClientB, it asks Kamailio, that know that SIP Client B is
registered on Asterisk 02 and so send the invite to it.
I'm going to work over this in the next few days and let you know the result,
if positive I'll write a new complete guide on this topic with your valuable suggestions.
Any suggestion is welcome
BR,
Anty
------------------------------------------------------------------------------------------------------
>> I have read and applied the excellent guide found on:
>> http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb
>>
>> Now I have added to Kamailio the HA/Load Balancer support, with the
>> "dispatcher" module.
>> This way I have 1 Kamailio and 2 Asterisk machines.
>>
>> How can I change the routing logic of the sections route[REGFWD] |
>> route[FROMASTERISK] route[TOASTERISK] to use the dispatcher module? (in the
>> guide above the asterisk binded ip address is cabled in the kamailio config
>> code)
I have done that. Relevant route entries below.
# Forward REGISTER to Asterisk
route[REGFWD] {
if(!is_method("REGISTER"))
{
return;
}
# for each Asterisk server in setid=2 (External) we send a registration on
behalf of the user.
sql_xquery("ca", "SELECT SUBSTRING_INDEX(destination,':',-1) AS port,
SUBSTRING_INDEX(SUBSTRING(destination,5),':',1) AS address
FROM dispatcher WHERE setid = 2", "ra");
$var(i) = 0;
while($xavp(ra[$var(i)]) != $null)
{
$var(rip) = $xavp(ra[$var(i)]=>address);
$uac_req(method)="REGISTER";
$uac_req(ruri)="sip:" + $var(rip) + ":" + $xavp(ra[$var(i)]=>port);
$uac_req(furi)="sip:" + $au + "@" + $var(rip);
$uac_req(turi)="sip:" + $au + "@" + $var(rip);
$uac_req(hdrs)="Contact: <sip:" + $au + "@"
+ $sel(cfg_get.kamailio.bindip)
+ ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";
if($sel(contact.expires) != $null)
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
"\r\n";
else
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
uac_req_send();
$var(i) = $var(i) + 1;
}
sql_result_free("ra");
}
# Test if coming from Asterisk. We check the dispatcher "ds_is_from_list()"
function to see if this is one of our Asterisk IPs
route[FROMASTERISK] {
if(ds_is_from_list())
{
return 1;
} else {
return -1;
}
}
# Send to Asterisk
route[TOASTERISK] {
# If call comes in to the .75 iface, we need to send it to the .75 iface of
Asterisk as well.
# otherwise we send to the .76 iface. We do this by calling different
dispatcher sets. This is
# because Asterisk needs to use NAT on the .76. (public) interface but not
on the .75.
if($td=~"10.5.75.")
{
$var(setid) = 4;
xlog("SCRIPT: Call to 10.5.75. ip - using set $var(setid) \n");
} else {
$var(setid) = 2;
xlog("SCRIPT: Call from $fn to 10.5.76. ip - using set $var(setid) \n");
}
# round robin dispatching on set determined above
if(!ds_select_dst($var(setid), "4"))
{
send_reply("404", "No destination");
exit;
}
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
Hope this helps.
-Barry Flanagan
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users