<div dir="ltr">Adding some more info:<br>It also can be tricky to manage Route headers via loose_route as Kamailio might not find an external (advertised ) IP and keep sending requests to this IP as it will present at the routes<br>There are 2 ways how to avoid it:<br> - Use one Record-Route and regex to change Record-Route header values depending on packet direction<br> - Use record_route_preset(addr1, addr2 ) and rewrite the loose_route() function behavior to force it to handle Route handing logic to make it possible to remove addresses Kamailio doesn't know<br><br>P.S. I believe Kamailio must remove all Route headers containing its addresses whether it is advertised or not, but at 5.5 it wasn't working for me in that way. I did not have a chance to spend much time diving into the source code and find why, but I rewrote loose_route on Lua with KEMI to make it work. The benefit I've got - the Kamailio script logic is now independent of the IP addresses it listens to.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 3 мая 2022 г. в 12:23, Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>>:<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>using two sockets for internal and external traffic is the easier
      way. The alternative is to use various functions from rr and core
      to set record-route and via headers.</p>
    <p>To detect what is the incoming local sockets, there are variables
      for received ip, port or socket name -- see the pv cookbook.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div>On 29.04.22 19:02, Carlos Escalona
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div class="gmail_default" style="font-family:arial,sans-serif"><br>
          Hello! I wish everyone who reads this message a good day.<br>
          <br>
          I would appreciate some guidance with the configuration of my
          Kamailio.<br>
          <br>
          Initially, I have the following architecture:<br>
          <br>
          Endpoints <----Public IP----> Kamailio (listen PrivateIP
          advertise PublicIP) <----Private IP----> Asterisk<br>
          <br>
          CONFIG: <a href="https://gist.github.com/Carlos-Escalona94/3a289af05b05c69ae563ab29c9ec4710" target="_blank">https://gist.github.com/Carlos-Escalona94/3a289af05b05c69ae563ab29c9ec4710</a><br>
          <br>
          In general, calls initiated from outside the system work
          perfectly, but I have a problem with calls initiated from
          Asterisk.<br>
          <br>
          According to what I was able to investigate and understand,
          the problem arises from the fact that Kamailio uses the public
          IP for the entire routing system that involves the
          Record-Route and Route Headers. This in turn causes Asterisk
          to get lost trying to send messages outside of the INITIAL
          INVITE transaction, for example, the ACK response to the 200
          Ok received from the Endpoint since it tries to use Kamailio's
          public IP to which Asterisk doesn't have access.<br>
          <br>
          I tried to force Asterisk to send all messages to Kamailio's
          private IP regardless of their nature, but it doesn't seem
          like an appropriate solution.<br>
          <br>
          On the other hand, I tried to modify the architecture a bit so
          that it was something similar to this:<br>
          <br>
          Endpoints <---- Public IP----> Kamailio (listen
          PrivateIP:P1 advertise PublicIP) <---- PrivateIP----->
          Kamailio (listen PrivateIP:P2) <---- PrivateIP ---->
          Asterisk<br>
          <br>
          CONFIG: <a href="https://gist.github.com/Carlos-Escalona94/4d681bb189c6190941d291965e123889" target="_blank">https://gist.github.com/Carlos-Escalona94/4d681bb189c6190941d291965e123889</a><br>
          <br>
          It seems to me that this would solve the problem, but I have
          two doubts about this architecture, the first is that I would
          like to know if there is an easier way to solve the problem
          that I am not considering, and on the other hand, I have not
          found a way to identify from which interface is receiving the
          message to perform the routing properly.<br>
          <br>
          <br>
          Thanks for the attention.
          <table style="color:rgb(25,28,43);font-family:Mulish,sans-serif;font-size:16px;direction:ltr;border-radius:0px">
            <tbody>
              <tr>
                <td><br>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <br>
      <font size="2" color="#808080"><i>Esta mensagem pode conter
          informação confidencial ou privilegiada, sendo seu sigilo
          protegido por lei. Se você não for o destinatário ou a pessoa
          autorizada a receber esta mensagem, não pode usar, copiar ou
          divulgar as informações nela contidas ou tomar qualquer ação
          baseada nessas informações. Se você recebeu esta mensagem por
          engano, por favor, avise imediatamente ao remetente,
          respondendo o e-mail e em seguida apague-a. Agradecemos sua
          cooperação.<br>
        </i></font>
      <div><font size="2" color="#808080"><i><br>
          </i></font></div>
      <div><font size="2" color="#808080"><i>This message may contain
            confidential or privileged information and its
            confidentiality is protected by law. If you are not the
            addressed or authorized person to receive this message, you
            must not use, copy, disclose or take any action based on it
            or any information herein. If you have received this message
            by mistake, please advise the sender immediately by replying
            the e-mail and then deleting it. Thank you for your
            cooperation.<br>
          </i></font></div>
      <div><br>
      </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
  * <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>

__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>