<div dir="ltr">Hello Daniel,<div><br></div><div>Thank you kindly for your advice. Sorry,I'm very new to Kamailio and still have no idea what to do.</div><div><br>Here is kamailio config of authentication section <br><br>##########################################<br> if (is_method("REGISTER") || from_uri==myself) {<br>                # authenticate requests<br>                if (!auth_check("$fd", "subscriber", "1")) {<br>                        auth_challenge("$fd", "0");<br>                        exit;<br>                }<br>                # user authenticated - remove auth header<br>                if(!is_method("REGISTER|PUBLISH"))<br>                        consume_credentials();<br>        }<br>        # if caller is not local subscriber, then check if it calls<br>        # a local destination, otherwise deny, not an open relay here<br>        if (from_uri!=myself && uri!=myself) {<br>                sl_send_reply("403","Not relaying");<br>                exit;<br>        }<br>############################################</div><div><br></div><div><br>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? <br>   <br>Sngrep SIP flow: <a href="https://drive.google.com/file/d/1aRHRbP3IDNll_FudwZGkV4aOQ0U9u_mt/view?usp=sharing">https://drive.google.com/file/d/1aRHRbP3IDNll_FudwZGkV4aOQ0U9u_mt/view?usp=sharing</a><br></div><div>Kamailio debug log: <a href="https://drive.google.com/file/d/1ZUGsEZUPbj9tspEdZFHSSvTdwqlm0YAp/view?usp=sharing">https://drive.google.com/file/d/1ZUGsEZUPbj9tspEdZFHSSvTdwqlm0YAp/view?usp=sharing</a><br>Kamaioio.cfg: <a href="https://drive.google.com/file/d/1m5ZcSTndcK_AqxI5Pt3UBEuiGv-pM75W/view?usp=sharing">https://drive.google.com/file/d/1m5ZcSTndcK_AqxI5Pt3UBEuiGv-pM75W/view?usp=sharing</a></div><div><br></div><div>Thanks,</div><div>Warawich</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 21, 2022 at 7:48 PM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Hello,</p>
    <p>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.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div>On 20.02.22 06:28, warawich wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>Hello,</div>
        <div><br>
        </div>
        <div>I would like to do a load balance between Asterisk SIP
          trunks.  You can see a diagram from this link:  <a href="https://drive.google.com/file/d/1Qy66L5rQCfxysYQpSd2-ek_8-by0T8PR/view?usp=sharing" target="_blank">https://drive.google.com/file/d/1Qy66L5rQCfxysYQpSd2-ek_8-by0T8PR/view?usp=sharing</a><br>
          <br>
          SIP Packets capture log: <a href="https://drive.google.com/file/d/1CHGUOwoRDAC93MMBtyfa8gBISKIVC-ng/view?usp=sharing" target="_blank">https://drive.google.com/file/d/1CHGUOwoRDAC93MMBtyfa8gBISKIVC-ng/view?usp=sharing</a></div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Details<br>
          1. Asterisk1 makes SIP trunk connection with Kamailio.<br>
          2. Kamailio makes SIP trunk connection with Asterisk2 and
          Asterisk3</div>
        <div>3. Caller register SIP phone with Asterisk1 <br>
               Caller extension = 8002<br>
          4. Asterisk2 makes a blind transfer to Kamailio. (Call to
          8009  then transfer to ARI APP)<br>
               exten = 8009,1,Transfer(SIP/3802@<kamailio public
          IP>)<br>
        </div>
        <div>5. ARI app extension is 3802</div>
        <div><br>
        </div>
        <div> </div>
        <div>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 <b>SIP/2.0 401 Unauthorized</b> in
          sip packets capture log.<br>
          <br>
          Kamailio version: 5.5.2<br>
          Kamailio.cfg<br>
          <br>
          modparam("dispatcher", "list_file",
          "/etc/kamailio/dispatcher.list")<br>
          modparam("dispatcher", "flags", 3)<br>
          modparam("dispatcher", "xavp_dst", "_dsdst_")<br>
          modparam("dispatcher", "xavp_ctx", "_dsctx_")<br>
          <br>
          # Dispatch requests<br>
          route[DISPATCH] {<br>
                  # round robin dispatching on gateways group '1'<br>
                  if(!ds_select_dst("1", "4")) {<br>
                          send_reply("404", "No destination");<br>
                          exit;<br>
                  }<br>
                  xdbg("--- SCRIPT: going to <$ru> via <$du>
          (attrs: $xavp(_dsdst_=>attrs))\n");<br>
                  t_on_failure("RTF_DISPATCH");<br>
                  route(RELAY);<br>
                  exit;<br>
          }<br>
          <br>
          # Try next destionations in failure route<br>
          failure_route[RTF_DISPATCH] {<br>
                  if (t_is_canceled()) {<br>
                          exit;<br>
                  }<br>
                  # next DST - only for 500 or local timeout<br>
                  if (t_check_status("500")<br>
                                  or (t_branch_timeout() and
          !t_branch_replied())) {<br>
                          if(ds_next_dst()) {<br>
                                  xdbg("--- SCRIPT: retrying to
          <$ru> via <$du> (attrs:
          $xavp(_dsdst_=>attrs))\n");<br>
                                  t_on_failure("RTF_DISPATCH");<br>
                                  route(RELAY);<br>
                                  exit;<br>
                          }<br>
                  }<br>
          }<br>
          <br>
          dispatcher.list<br>
          # setid(int) destination(sip uri) flags(int,opt)
          priority(int,opt) attrs(str,opt)<br>
          1 sip:<a href="http://10.148.0.31:5123" target="_blank">10.148.0.31:5123</a><br>
          1 sip:<a href="http://10.148.0.44:5123" target="_blank">10.148.0.44:5123</a><br>
          <br>
          Thanks,</div>
        <div>Warawich<br>
          <br>
          <br>
          <br>
          <br>
          <br>
          <br>
          <br>
          <br>
          <br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
  Feb 21-24, 2022 (America Timezone)
  * <a href="https://www.asipto.com/sw/kamailio-advanced-training-online/" target="_blank">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </div>

</blockquote></div>