<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div>Hi, again,</div><div><br></div><div>Did this work any time before?</div><div>I have force_rport(),  fix_nated_register() active and as follows:<br></div><div>










</div><p class="p1"><span class="s1">if (nat_uac_test("diff-ip-src-contact")) {</span></p><div>
</div><p class="p1"><span class="s1">if (is_method("REGISTER")) {</span></p><div>
</div><p class="p2"><span class="s3">fix_nated_register();</span></p><div>
</div><p class="p2"><span class="s3">setbflag("NAT");</span></p><div>
</div><p class="p2"><span class="s3">} else {</span></p><div>
</div><p class="p2"><span class="s3">fix_nated_contact();  <<<<<<<<<</span></p><div>
</div><p class="p2"><span class="s3">setflag("NAT");</span></p><div>
</div><p class="p2"><span class="s3">}</span></p><div>
</div><p class="p2"><span class="s3">}</span></p><div><br></div><div><span class="s3">But in my tcpdump I only see 1 natted address. Which would mean opensips suddenly forgets the register with the other natted address </span> fix_nated_register().</div><div>we would like to see both natted ip adresses. The public IPv4 address is the only one addressed.</div><div><br></div><div><br></div><div>Regards</div><div><br></div><div>Ronald</div><div><br></div><div><br></div><div><br></div><div><br></div><p>September 2, 2023 at 2:17 AM, "Ray Jackson" <<a href="mailto:ray@hero.co.nz?to=%22Ray%20Jackson%22%20%3Cray%40hero.co.nz%3E" target="_blank" tabindex="-1">ray@hero.co.nz</a>> wrote:</p><blockquote><div><div>
    </div><p>Hi all,</p><div>
    </div><p>I'm facing a weird issue which I think is related to broken TCP
      socket reuse logic where the wrong client is receiving incoming
      calls due to the wrong socket being used for the incoming INVITE.
    </p><div>
    </div><p>The scenario is when I have 2 clients registering using TLS
      behind NAT at the same Public IPv4 address and both clients are
      using the same private port number.  So client 1 registers and the
      Via and contact header looks like:
    </p><div>
    </div><p><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>Via: </b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'> SIP/2.0/TLS 192.168.42.162:5062;</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>branch=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>z9hG4bK1409895926;rport;alias
</span>
<span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>Contact: </b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'> <<a href="sip:201@192.168.42.162:5062" target="_blank" tabindex="-1">sip:201@192.168.42.162:5062</a>;</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>transport=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>tls>;</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>reg-id=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>2;+sip.instance="<a href="urn:uuid:00000000-0000-1000-8000-C074AD928AC4" target="_blank" tabindex="-1"><urn:uuid:00000000-0000-1000-8000-C074AD928AC4></a>"</span></p><div>
    </div><p>Client 2 registers from behind the same Public IPv4 address and
      the Via and contact header looks like:</p><div>
    </div><p><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>Via: </b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'> SIP/2.0/TLS 192.168.42.186:5062;</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>branch=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>z9hG4bK-aff1f3b3
</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>Contact: </b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'> <<a href="sip:202@192.168.42.186:5062" target="_blank" tabindex="-1">sip:202@192.168.42.186:5062</a>;</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>transport=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>tls>;expire</span><span style='box-sizing: border-box; color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'><b>s=</b></span><span style='color: rgb(80, 80, 80); font-family: Roboto, "Helvetica Neue", sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;'>300</span></p><div>
    </div><p>The location table shows Client 1 received field of
      103.212.1.2:5062 and Client 103.212.1.2:23456 
    </p><div>
    </div><p>When a call comes in for Client 1 the location lookup seems to
      return the correct 'received' address and port (e.g.
      103.212.1.2:5062) and all the logs indicate that this is where the
      SIP INVITE *should* be going to (in the $du field).  However when
      you check the SIP traffic it selects Client 2's socket and the
      traffic goes to port 23456 instead of 5062.</p><div>
    </div><p>I think this is related somehow to the TCP port reuse logic
      inside Opensips.  My suspicion is that Opensips is looking at the
      Contact or Via port number (which is the same for both client 1
      and 2) and then somehow mapping this to the wrong TCP received
      socket.</p><div>
    </div><p>Does anybody have any suggestions here?  Should I be fixing the
      NAT in the Contact header (using fix_nated_contact).  I read
      somewhere that you shouldn't rewrite the Contact header to avoid
      problems with sending a different Contact URI to the client on
      calls.  Or is this issue more related to the Via header and the
      TCP port reuse logic looking at this port instead of the actual
      received port when choosing the outgoing socket?</p><div>
    </div><p>FYI: I am using both force_rport() and fix_nated_register() for
      incoming registrations from these clients and matching_mode of 0
      in usrloc.  However, I am not using fix_nated_contact() for
      registrations.</p><div>
    </div><p>Thanks,</p><div>
    </div><p>Ray
    </p><div>
    </div><p>
      </p><div>
  </div></div></blockquote><div><br></div></body></html>