Hi list,
I'm new here, also to Kamailio. My goal is to achieve the "standard solution": Kamailio for load balancing and high availability of several Asterisk servers.
For starters, I've set it up with Kamailio+dispatcher+permissions acting as a proxy and it was working fine, but I'd like to try to keep it much more simple. For these reasons:
1) I'd like to maintain different peer settings in Asterisk (DTMF, codecs).
2) I don't want/need a database for Kamailio. I think it is mandatory for permissions module + IP auth. So, let's do Asterisk the authentication, it's already there.
3) Accounting. I'm using a software where it's really useful for accounting purposes if every peer/user has its own entry in Asterisk's sip.conf / in realtime table.
Long story short, my config now looks like this and it seems to be working fine for me:
request_route { route(DISPATCHER); }
route[DISPATCHER] {
if ( method=="REGISTER") { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
if ( method=="INVITE" ) { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
if ( method=="SUBSCRIBE" ) { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
}
My questions:
1) There are other approaches to the DTMF+codecs issue. Like this thread from 2013: http://lists.kamailio.org/pipermail/sr-users/2013-January/076379.html - but I have dozens of changing PSTN peers, so authentication/accounting based on port would be cumbersome. Are there new/alternative ways?
2) I searched the archive and the Web but did not find many questions about a "I-don't-want-Kamailio-to-show-as-the-only-peer-to-Asterisk" solution. Therefore I'm wondering: Is everyone a) running such homogeneous setups that they can survive with the same codec + DTMF settings in Asterisk for all their peers + users? Or b) doing some rewriting magic within Kamailio to deal with it? Or c) I'm overlooking a simple solution. Which one is it? :)
3) And the biggest question: Everywhere I read basically "Redirect server for LB + HA is not recommended, better use proxy". Is this still true, and if so, what are the reasons? Because I should be worried that not all clients/gateways out there respect a SIP 300 Redirect? Other reasons?
Thanks so much! :) Markus
Hello,
On 13/03/15 08:52, Markus wrote:
Hi list,
I'm new here, also to Kamailio. My goal is to achieve the "standard solution": Kamailio for load balancing and high availability of several Asterisk servers.
For starters, I've set it up with Kamailio+dispatcher+permissions acting as a proxy and it was working fine, but I'd like to try to keep it much more simple. For these reasons:
- I'd like to maintain different peer settings in Asterisk (DTMF,
codecs).
- I don't want/need a database for Kamailio. I think it is mandatory
for permissions module + IP auth. So, let's do Asterisk the authentication, it's already there.
You can use here db_text or db_sqlite, which don't require a heavy mysql server. You can also have static rules in kamailio, like:
if(src_ip==asterisk_ip1 || src_ip==asterisk_ip1 || ...)
Or, if asterisk servers are in the same subnet, you can have:
if(src_ip==asterisk_net/24)
As you use dispatcher, another alternative is to use ds_is_from_list() function, which will match if the request was sent by one of addresses in the dispatcher lists.
- Accounting. I'm using a software where it's really useful for
accounting purposes if every peer/user has its own entry in Asterisk's sip.conf / in realtime table.
Long story short, my config now looks like this and it seems to be working fine for me:
request_route { route(DISPATCHER); }
route[DISPATCHER] {
if ( method=="REGISTER") { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
if ( method=="INVITE" ) { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
if ( method=="SUBSCRIBE" ) { ds_select_domain("1","4"); sl_send_reply("300","Redirect"); exit; }
}
My questions:
- There are other approaches to the DTMF+codecs issue. Like this
thread from 2013: http://lists.kamailio.org/pipermail/sr-users/2013-January/076379.html
- but I have dozens of changing PSTN peers, so
authentication/accounting based on port would be cumbersome. Are there new/alternative ways?
- I searched the archive and the Web but did not find many questions
about a "I-don't-want-Kamailio-to-show-as-the-only-peer-to-Asterisk" solution. Therefore I'm wondering: Is everyone a) running such homogeneous setups that they can survive with the same codec + DTMF settings in Asterisk for all their peers + users? Or b) doing some rewriting magic within Kamailio to deal with it? Or c) I'm overlooking a simple solution. Which one is it? :)
Can asterisk make some decision on headers? IIRC, someone was mentioning at some point to use Remote-Party-ID (could be now P-Asserted-Identity) header to match on a specific profile.
- And the biggest question: Everywhere I read basically "Redirect
server for LB + HA is not recommended, better use proxy". Is this still true, and if so, what are the reasons? Because I should be worried that not all clients/gateways out there respect a SIP 300 Redirect? Other reasons?
I think this is something specific for your environment. Kamailio doesn't have any issues sending redirect replies. A proxy might be required in case of natted endpoints when they cannot communicate each other. But otherwise, if you don't want the new INVITE to pass again via LB, then you can send 3xx.
Cheers, Daniel
Hi Daniel,
Am 13.03.2015 um 09:47 schrieb Daniel-Constantin Mierla:
Can asterisk make some decision on headers? IIRC, someone was mentioning at some point to use Remote-Party-ID (could be now P-Asserted-Identity) header to match on a specific profile.
I don't know. I'll ask in the Asterisk list. But based on your answer it really seems this is a scenario that not many people need or ask for.
I'd love to find out why this is the case. I would have estimated 9 out of 10 people need to fine-tune DTMF + codec settings in Asterisk.
I think this is something specific for your environment. Kamailio doesn't have any issues sending redirect replies. A proxy might be required in case of natted endpoints when they cannot communicate each other. But otherwise, if you don't want the new INVITE to pass again via LB, then you can send 3xx.
Other than communication between natted endpoints you don't see any disadvantage of using Kamailio for LB+HA as Redirect server instead as proxy server?
Thanks! Markus
On 13 Mar 2015, at 16:39, Markus universe@truemetal.org wrote:
Hi Daniel,
Am 13.03.2015 um 09:47 schrieb Daniel-Constantin Mierla:
Can asterisk make some decision on headers? IIRC, someone was mentioning at some point to use Remote-Party-ID (could be now P-Asserted-Identity) header to match on a specific profile.
I don't know. I'll ask in the Asterisk list. But based on your answer it really seems this is a scenario that not many people need or ask for.
I'd love to find out why this is the case. I would have estimated 9 out of 10 people need to fine-tune DTMF + codec settings in Asterisk.
The most common solution I've seen is to have kamailio use 10 different ports and have 10 different matching peers in the Asterisk SIP config to select settings.
/O
On Friday 13 March 2015 17:14:31 Olle E. Johansson wrote:
I'd love to find out why this is the case. I would have estimated 9 out of 10 people need to fine-tune DTMF + codec settings in Asterisk.
The most common solution I've seen is to have kamailio use 10 different ports and have 10 different matching peers in the Asterisk SIP config to select settings.
Cumbersome, why not just use some custom headers (stored in usr_preferences)?
kamailio stuff: if($avp(src_dtmfmode)!="") { append_hf("X-DTMFMode: $avp(src_dtmfmode)\r\n"); }
asterisk stuff: exten => _[+X].,n,ExecIf($[${LEN(${SIP_HEADER(X-DTMFMode)})} > 0]?SIPDtmfMode(${SIP_HEADER(X-DTMFMode)}))
The other way around is bit more tricky. YOu have to dial using the M option (i'm using AGI instead of RT): M(setdtmftx^".$row['dtmftx'].")
[macro-setdtmftx] exten => s,1,NoOp() exten => s,n,SIPDtmfMode(${ARG1}) exten => s,n,MacroExit
On 13 Mar 2015, at 18:45, Daniel Tryba d.tryba@pocos.nl wrote:
On Friday 13 March 2015 17:14:31 Olle E. Johansson wrote:
I'd love to find out why this is the case. I would have estimated 9 out of 10 people need to fine-tune DTMF + codec settings in Asterisk.
The most common solution I've seen is to have kamailio use 10 different ports and have 10 different matching peers in the Asterisk SIP config to select settings.
Cumbersome, why not just use some custom headers (stored in usr_preferences)?
There are settings you can't set from the dialplan, but when you can this is a good idea.
/O
kamailio stuff: if($avp(src_dtmfmode)!="") { append_hf("X-DTMFMode: $avp(src_dtmfmode)\r\n"); }
asterisk stuff: exten => _[+X].,n,ExecIf($[${LEN(${SIP_HEADER(X-DTMFMode)})} > 0]?SIPDtmfMode(${SIP_HEADER(X-DTMFMode)}))
The other way around is bit more tricky. YOu have to dial using the M option (i'm using AGI instead of RT): M(setdtmftx^".$row['dtmftx'].")
[macro-setdtmftx] exten => s,1,NoOp() exten => s,n,SIPDtmfMode(${ARG1}) exten => s,n,MacroExit
--
Telefoon: 088 0100 700 Sales: sales@pocos.nl | Service: servicedesk@pocos.nl http://www.pocos.nl/ | Croy 9c, 5653 LC Eindhoven | Kamer van Koophandel 17097024
On Fri, Mar 13, 2015 at 08:16:50PM +0100, Olle E. Johansson wrote:
Cumbersome, why not just use some custom headers (stored in usr_preferences)?
There are settings you can't set from the dialplan, but when you can this is a good idea.
With modern Asterisks is has been a long time since I needed anything that wasn't available from the dialplan (can't think of anything).
On 13 Mar 2015, at 20:34, Daniel Tryba d.tryba@pocos.nl wrote:
On Fri, Mar 13, 2015 at 08:16:50PM +0100, Olle E. Johansson wrote:
Cumbersome, why not just use some custom headers (stored in usr_preferences)?
There are settings you can't set from the dialplan, but when you can this is a good idea.
With modern Asterisks is has been a long time since I needed anything that wasn't available from the dialplan (can't think of anything).
Good. Then we've done a good job with Asterisk. :-)
Thank you for the feedback.
/O
On 13/03/15 16:39, Markus wrote:
[...]
I think this is something specific for your environment. Kamailio doesn't have any issues sending redirect replies. A proxy might be required in case of natted endpoints when they cannot communicate each other. But otherwise, if you don't want the new INVITE to pass again via LB, then you can send 3xx.
Other than communication between natted endpoints you don't see any disadvantage of using Kamailio for LB+HA as Redirect server instead as proxy server? From Kamailio point of view, there is nothing. When doing redirect, the
accounting for new calls (resulted from redirect) is no longer possible on the sip server, but I guess that is not something you look for in this scenario.
Cheers, Daniel