<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello again</p>
    <p>I have attached a Capture.</p>
    <p>My public IP is 194.255.22.44, and I have a port forward of 5071
      in my router</p>
    <p>The Raspberry Pi running the Kamailio is on 192.168.2.9 with an
      alias 192.168.2.40</p>
    <p>My listening is setup like this<br>
    </p>
    <p>listen=127.0.0.1:5071<br>
      listen=eth0:5071  advertise 194.255.22.44:5071<br>
      alias=194.255.22.44:5071<br>
    </p>
    <p>Kamailio is forwarding an invite from a door phone thus I also
      rewrite FROM:</p>
    <p>uac_replace_from("sip:"+$dbr(ra=>[0,1])+"@194.255.22.44:5071");<br>
      And the failure route to<br>
      $fu = "sip:"+$dbr(ra=>[0,0])+"@194.255.22.44:5071";<br>
      <br>
    </p>
    <p>In the route doing the INVITE I also set this:<br>
    </p>
    <p>set_advertised_address("194.255.22.44:5071");<br>
    </p>
    <p><br>
    </p>
    <p>Regarding tcp_reuse_port, if I set this I get this error, which I
      understand is due to the way TCP works.<br>
    </p>
    <p>Nov  4 18:38:41 scantronpbx /usr/sbin/kamailio[15864]: {1 ACK
      16191 ACK C2Az-Xm2b0CEPyV5eQuz7yEf9IJo4PyJ} WARNING: <core>
      [core/tcp_main.c:1061]: tcp_do_connect(): binding to source
      address 192.168.2.40:5071 failed: Address already in use [98]</p>
    <p>I do have tcp_reuse_port=yes with this capture. But much to my
      surprise, the 200 OK from is send to 37148, but the ACK to it
      comes from 37150<br>
    </p>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-------------------- Med Liberalistiske Hilsner ----------------------
   Civilingeniør, Kjeld Flarup - Mit sind er mere åbent end min tegnebog
   Sofienlundvej 6B, 7560 Hjerm, Tlf: 40 29 41 49
   Den ikke akademiske hjemmeside for liberalismen - <a class="moz-txt-link-abbreviated" href="http://www.liberalismen.dk">www.liberalismen.dk</a></pre>
    <div class="moz-cite-prefix">On 11/4/20 1:59 PM, Carsten Bock wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOCjumHCpV1JxoW+wS6pT4V3YKcYziJ=9eqEbpnKO3kvZZBOXg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I think you are searching for this parameter:</div>
        <div><br>
        </div>
        <div><a
            href="http://www.kamailio.org/wiki/cookbooks/devel/core#tcp_reuse_port"
            moz-do-not-send="true">http://www.kamailio.org/wiki/cookbooks/devel/core#tcp_reuse_port</a><br>
        </div>
        <div><br>
        </div>
        <div>It basically tells the kernel not to choose a new port at
          random for a new connection, but it will try to reuse the
          existing port (in your case 5071).</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Carsten</div>
        <div><br>
        </div>
        <div><br clear="all">
          <div>
            <div dir="ltr" data-smartmail="gmail_signature">
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">--</div>
                      <div dir="ltr">Carsten Bock I CTO & Founder</div>
                      <div dir="ltr"><br>
                        <p style="margin:0cm 0cm
0.0001pt;background-image:initial;background-position:initial;background-repeat:initial"><span
                            style="color:black" lang="EN-US">ng-voice
                            GmbH</span><span
                            style="color:rgb(0,112,192)" lang="EN-US"></span></p>
                        <p
style="margin-right:0cm;margin-bottom:12pt;margin-left:0cm;background-image:initial;background-position:initial;background-repeat:initial"><span
                            style="color:black" lang="EN-US">Trostbrücke
                            1 I 20457 Hamburg I Germany<br>
                            T +49 40 524 75 93-40 | M +49 179 2021244 I <a
                              href="http://www.ng-voice.com/"
                              style="color:rgb(17,85,204)"
                              target="_blank" moz-do-not-send="true"><span
                                style="color:black">www.ng-voice.com</span></a></span></p>
                        <p style="margin:0cm 0cm
0.0001pt;background-image:initial;background-position:initial;background-repeat:initial"><span
                            style="color:black" lang="EN-US">Registry
                            Office at Local Court Hamburg, HRB 120189<br>
                            Managing Directors: Dr. David Bachmann,
                            Carsten Bock</span></p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Am Mi., 4. Nov. 2020 um
          12:07 Uhr schrieb Kjeld Flarup <<a
            href="mailto:kjeld.flarup@liberalismen.dk" target="_blank"
            moz-do-not-send="true">kjeld.flarup@liberalismen.dk</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">Hello<br>
          <br>
          I have a Kamailio running behind NAT, which sends calls to a
          VOIP <br>
          service provider.<br>
          <br>
          I have setup the Kamalio to listen on port 5071, and also
          setup a port <br>
          forward in the router.<br>
          <br>
          Now the problem is that with TCP, 5071 is not used for the
          dialog, but a <br>
          new port is chosen everytime. This means that when the mobile
          phone <br>
          called hands up, I never sees the BYE, because BYE is a new
          dialog.<br>
          <br>
          <br>
          To which port is the server supposed to send the BYE, and what
          field <br>
          tells the server this.<br>
          <br>
          <br>
          -- <br>
          -------------------- Med Liberalistiske Hilsner
          ----------------------<br>
              Civilingeniør, Kjeld Flarup - Mit sind er mere åbent end
          min tegnebog<br>
              Sofienlundvej 6B, 7560 Hjerm, Tlf: 40 29 41 49<br>
              Den ikke akademiske hjemmeside for liberalismen - <a
            href="http://www.liberalismen.dk" rel="noreferrer"
            target="_blank" moz-do-not-send="true">www.liberalismen.dk</a><br>
          <br>
          <br>
          _______________________________________________<br>
          Kamailio (SER) - Users Mailing List<br>
          <a href="mailto:sr-users@lists.kamailio.org" target="_blank"
            moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
          <a
            href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
  </body>
</html>