[SR-Users] Dispatcher Load Balance with SIP Trunk

warawich warawich at gmail.com
Thu Feb 24 08:08:07 CET 2022


Hello Daniel,

Thank you kindly for your advice. Sorry,I'm very new to Kamailio and still
have no idea what to do.

Here is kamailio config of authentication section

##########################################
 if (is_method("REGISTER") || from_uri==myself) {
                # authenticate requests
                if (!auth_check("$fd", "subscriber", "1")) {
                        auth_challenge("$fd", "0");
                        exit;
                }
                # user authenticated - remove auth header
                if(!is_method("REGISTER|PUBLISH"))
                        consume_credentials();
        }
        # if caller is not local subscriber, then check if it calls
        # a local destination, otherwise deny, not an open relay here
        if (from_uri!=myself && uri!=myself) {
                sl_send_reply("403","Not relaying");
                exit;
        }
############################################


As I checked from sngrep, SIP invites go to both destinations Asterisk 2
and Asterisk 3 and then return error 401 authen. I'm not sure if it would
go to the only one SIP destination or not?

Sngrep SIP flow:
https://drive.google.com/file/d/1aRHRbP3IDNll_FudwZGkV4aOQ0U9u_mt/view?usp=sharing
Kamailio debug log:
https://drive.google.com/file/d/1ZUGsEZUPbj9tspEdZFHSSvTdwqlm0YAp/view?usp=sharing
Kamaioio.cfg:
https://drive.google.com/file/d/1m5ZcSTndcK_AqxI5Pt3UBEuiGv-pM75W/view?usp=sharing

Thanks,
Warawich

On Mon, Feb 21, 2022 at 7:48 PM Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> Hello,
>
> if you see 401 being returned by Kamailio, then the config file execution
> ends in calling auth_challenge() or a similar *_challenge() function from
> auth* modules. That means you do not match the traffic to use dispatcher
> for routing. You can set debug=3 to view more debug messages printed by
> kamaialio or use debugger module with cfgtrace enabled in order to see what
> configuration file actions are executed and see if you can identify why
> execution is not going where you expect to go.
>
> Cheers,
> Daniel
> On 20.02.22 06:28, warawich wrote:
>
> Hello,
>
> I would like to do a load balance between Asterisk SIP trunks.  You can
> see a diagram from this link:
> https://drive.google.com/file/d/1Qy66L5rQCfxysYQpSd2-ek_8-by0T8PR/view?usp=sharing
>
> SIP Packets capture log:
> https://drive.google.com/file/d/1CHGUOwoRDAC93MMBtyfa8gBISKIVC-ng/view?usp=sharing
>
>
> Details
> 1. Asterisk1 makes SIP trunk connection with Kamailio.
> 2. Kamailio makes SIP trunk connection with Asterisk2 and Asterisk3
> 3. Caller register SIP phone with Asterisk1
>      Caller extension = 8002
> 4. Asterisk2 makes a blind transfer to Kamailio. (Call to 8009  then
> transfer to ARI APP)
>      exten = 8009,1,Transfer(SIP/3802@<kamailio public IP>)
> 5. ARI app extension is 3802
>
>
> My problem is that Kamailio LB only works when I try to connect
> with Asterisk1 and Asterisk2 or  Asterisk1 and Asterisk3. If I have two
> Asterisks in dispatcher.list, it doesn't work and it appears *SIP/2.0 401
> Unauthorized* in sip packets capture log.
>
> Kamailio version: 5.5.2
> Kamailio.cfg
>
> modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
> modparam("dispatcher", "flags", 3)
> modparam("dispatcher", "xavp_dst", "_dsdst_")
> modparam("dispatcher", "xavp_ctx", "_dsctx_")
>
> # Dispatch requests
> route[DISPATCH] {
>         # round robin dispatching on gateways group '1'
>         if(!ds_select_dst("1", "4")) {
>                 send_reply("404", "No destination");
>                 exit;
>         }
>         xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs:
> $xavp(_dsdst_=>attrs))\n");
>         t_on_failure("RTF_DISPATCH");
>         route(RELAY);
>         exit;
> }
>
> # Try next destionations in failure route
> failure_route[RTF_DISPATCH] {
>         if (t_is_canceled()) {
>                 exit;
>         }
>         # next DST - only for 500 or local timeout
>         if (t_check_status("500")
>                         or (t_branch_timeout() and !t_branch_replied())) {
>                 if(ds_next_dst()) {
>                         xdbg("--- SCRIPT: retrying to <$ru> via <$du>
> (attrs: $xavp(_dsdst_=>attrs))\n");
>                         t_on_failure("RTF_DISPATCH");
>                         route(RELAY);
>                         exit;
>                 }
>         }
> }
>
> dispatcher.list
> # setid(int) destination(sip uri) flags(int,opt) priority(int,opt)
> attrs(str,opt)
> 1 sip:10.148.0.31:5123
> 1 sip:10.148.0.44:5123
>
> Thanks,
> Warawich
>
>
>
>
>
>
>
>
>
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the sender!
> Edit mailing list options or unsubscribe:
>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
> --
> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
> Kamailio Advanced Training - Online
>   Feb 21-24, 2022 (America Timezone)
>   * https://www.asipto.com/sw/kamailio-advanced-training-online/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220224/aa226113/attachment.htm>


More information about the sr-users mailing list