<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">See inline</font><br>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS eBootcamp 23rd May - 3rd June 2022
  <a class="moz-txt-link-freetext" href="https://opensips.org/training/OpenSIPS_eBootcamp_2022/">https://opensips.org/training/OpenSIPS_eBootcamp_2022/</a></pre>
    <div class="moz-cite-prefix">On 5/3/22 11:40 AM, Yury Kirsanov
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAD1_seuJQmFnDpUbKxy5v=QGAAXAB9a04ktKODjn1bf3Rxc+cg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Bogdan,
        <div>Will fix_nated_register() overwrite results of a
          fix_nated_contact()?</div>
      </div>
    </blockquote>
    no, use either one, either the other, but not both in the same time
    - see the docs for the nathelper module for details.<br>
    <blockquote type="cite"
cite="mid:CAD1_seuJQmFnDpUbKxy5v=QGAAXAB9a04ktKODjn1bf3Rxc+cg@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Second question - for 'OPTIONS' where Contact is available
          - should fix_nated_contact() replace it with the correct one?</div>
      </div>
    </blockquote>
    yes, if you relay the OPTIONS<br>
    <blockquote type="cite"
cite="mid:CAD1_seuJQmFnDpUbKxy5v=QGAAXAB9a04ktKODjn1bf3Rxc+cg@mail.gmail.com">
      <div dir="ltr">
        <div> Where exactly does this function take the value to replace
          Contact with - from '$avp(received)' param?</div>
      </div>
    </blockquote>
    no, it is taken from the network level, the src IP and port.<br>
    <blockquote type="cite"
cite="mid:CAD1_seuJQmFnDpUbKxy5v=QGAAXAB9a04ktKODjn1bf3Rxc+cg@mail.gmail.com">
      <div dir="ltr">
        <div> So it won't do anything if, for example, OPTIONS packet
          comes from my LAN Asterisk server and reaches the OpenSIPS LAN
          interface?</div>
      </div>
    </blockquote>
    the fix_nated_xxxX() does not do any testing, it simply replace the
    host:port part of the contact with the src IP and port from network
    level.<br>
    <blockquote type="cite"
cite="mid:CAD1_seuJQmFnDpUbKxy5v=QGAAXAB9a04ktKODjn1bf3Rxc+cg@mail.gmail.com">
      <div dir="ltr">
        <div> Even though nat_uac_test(7) would confirm a RFC1918
          private address fix_nated_contact() can't do much in this
          case, is that correct? </div>
        <div><br>
        </div>
        <div>Thanks a lot for your help!</div>
        <div><br>
        </div>
        <div>Best regards,</div>
        <div>Yury.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, May 3, 2022 at 6:25 PM
          Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org"
            moz-do-not-send="true">bogdan@opensips.org</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> <font face="monospace">Hi Yury,<br>
              <br>
              For a REGISTER you should use the fix_nated_register()
              function.<br>
              <br>
              Regards,<br>
            </font>
            <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS eBootcamp 23rd May - 3rd June 2022
  <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2022/" target="_blank" moz-do-not-send="true">https://opensips.org/training/OpenSIPS_eBootcamp_2022/</a></pre>
            <div>On 5/2/22 8:07 PM, Yury Kirsanov wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">Hi Bogdan,
                <div>No, nothing in OpenSIPS logs, unfortunately.</div>
                <div><br>
                </div>
                <div>Here's another log, I'm doing 'fix_nated_register'
                  in this case at the REGISTER route and doing
                  'fix_nated_contact()' at the very beginning of my
                  script, just for the testing purpose.<br>
                  <br>
                  May  3 03:00:48 [REGISTER]      [123456->123456]
                  Forwarding REGISTER from <a
                    href="http://sip:123456@domain.com:5060"
                    target="_blank" moz-do-not-send="true">sip:123456@domain.com:5060</a>,
                  requested Expries: 60 to main registrar at sip:<a
                    href="http://172.16.4.22:5060" target="_blank"
                    moz-do-not-send="true">172.16.4.22:5060</a>
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [REPLY]         [123456->123456]
                  REGISTER 401 Unauthorized FROM <a
                    href="http://172.16.4.22:5060" target="_blank"
                    moz-do-not-send="true">172.16.4.22:5060</a>
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [REGISTER]      [123456->123456]
                  Request from 1XX.1XX.1XX.1XX:8001, domain <a
                    href="http://domain.com" target="_blank"
                    moz-do-not-send="true">domain.com</a>
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [REGISTER]      [123456->123456]
                  Forwarding REGISTER from <a
                    href="http://sip:123456@domain.com:5060"
                    target="_blank" moz-do-not-send="true">sip:123456@domain.com:5060</a>,
                  requested Expries: 60 to main registrar at sip:<a
                    href="http://172.16.4.22:5060" target="_blank"
                    moz-do-not-send="true">172.16.4.22:5060</a>
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [REPLY]         [123456->123456]
                  REGISTER 200 OK FROM <a
                    href="http://172.16.4.22:5060" target="_blank"
                    moz-do-not-send="true">172.16.4.22:5060</a>
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [REGREPLY]      [123456->123456]
                  Reply from <a href="http://172.16.4.22:5060"
                    target="_blank" moz-do-not-send="true">172.16.4.22:5060</a>,
                  code is 200 - OK, saving contact
                  (84327f479c5d50e1634422f72a0b7619)<br>
                  May  3 03:00:48 [EVENT] Inserting contact <a
                    href="http://sip:123456@192.168.1.36:8001"
                    target="_blank" moz-do-not-send="true">sip:123456@192.168.1.36:8001</a>
                  (569f6c324981335e0b33daf8fc88ed77)<br>
                  May  3 03:00:51 [OPTIONS]       OPTIONS request from <a
                    href="http://172.16.4.22:5060" target="_blank"
                    moz-do-not-send="true">172.16.4.22:5060</a> to <a
                    href="http://sip:123456@172.16.4.254:5060"
                    target="_blank" moz-do-not-send="true">sip:123456@172.16.4.254:5060</a>,
                  fu is <a moz-do-not-send="true">sip:123456@1XX.1XX.1XX.1XX</a><br>
                  May  3 03:00:51 [OPTIONS]       [123456->123456]
                  SIP device <a href="mailto:sip%3A123456@172.16.4.254"
                    target="_blank" moz-do-not-send="true">sip:123456@172.16.4.254</a>
                  found, relaying to <a moz-do-not-send="true">sip:1XX.1XX.1XX.1XX:8001</a>
                  (76f4319976c85e45b2ff916581912550)<br>
                </div>
                <div><br>
                </div>
                <div>No errors in OpenSIPS logs. Here's output of
                  'opensips-cli -x mi fifo ul_dump':</div>
                <div><br>
                              "AORs": [<br>
                                  {<br>
                                      "AOR": "123456",<br>
                                      "Contacts": [<br>
                                          {<br>
                                              "Contact": "<a
                    href="http://sip:123456@192.168.1.36:8001"
                    target="_blank" moz-do-not-send="true">sip:123456@192.168.1.36:8001</a>",<br>
                                              "ContactID":
                  "3713509073413807284",<br>
                                              "Expires": 47,<br>
                                              "Q": "",<br>
                                              "Callid": "6_3941098626",<br>
                                              "Cseq": 2,<br>
                                              "User-agent": "Yealink
                  SIP-T46G 28.83.0.120",<br>
                                              "Received": <a
                    moz-do-not-send="true">"sip:1XX.1XX.1XX.1XX:8001"</a>,<br>
                                              "State": "CS_SYNC",<br>
                                              "Flags": 0,<br>
                                              "Cflags": "",<br>
                                              "Socket":
                  "udp:1XX.1XX.1XX.1XX:5060",<br>
                                              "Methods": 16383<br>
                                          }<br>
                                      ]<br>
                                  }<br>
                </div>
                <div><br>
                </div>
                <div>Thanks and best regards,</div>
                <div>Yury.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Tue, May 3, 2022 at
                  12:29 AM Bogdan-Andrei Iancu <<a
                    href="mailto:bogdan@opensips.org" target="_blank"
                    moz-do-not-send="true">bogdan@opensips.org</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> <font face="monospace">Hi,<br>
                      <br>
                      Are there any errors when the "fixing" is done?
                      The presence of a param should not impact here.<br>
                      <br>
                      Regards,<br>
                      Bogdan<br>
                    </font>
                    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS eBootcamp 23rd May - 3rd June 2022
  <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2022/" target="_blank" moz-do-not-send="true">https://opensips.org/training/OpenSIPS_eBootcamp_2022/</a></pre>
                    <div>On 4/29/22 1:43 PM, Yury Kirsanov wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hi,
                        <div>I'm using OpenSIPS 3.2.4 and recently run
                          into following issue:</div>
                        <div><br>
                        </div>
                        <div>Imagine simplest proxy setup - OpenSIPS
                          just accepts new packet, for example INVITE,
                          changes destination using 'sethostport(....)'
                          and then issues 't_relay()' to forward the
                          packet. Let's ignore replies and so on.</div>
                        <div><br>
                        </div>
                        <div>If I'm doing a 'fix_nated_contact()' before
                          sending this packet I'm expecting Contact:
                          field to be replaced with a source IP:port as
                          per manual. And this works if the Contact is
                          in simple form like '<a
                            href="http://sip:7777777@192.168.29.106:65033"
                            target="_blank" moz-do-not-send="true">sip:7777777@192.168.29.106:65033</a>'.</div>
                        <div><br>
                        </div>
                        <div>But if following Contact comes in OpenSIPS
                          doesn't change it leaving private IP in the
                          contact:</div>
                        <div><br>
                        </div>
                        <div>'Contact: <a moz-do-not-send="true">sip:7777777@192.168.29.106:65033;rinstance=2f59b175103f1088</a>'<br>
                        </div>
                        <div><br>
                        </div>
                        <div>Can you please let me know why is that
                          happening? Thanks!<br>
                        </div>
                        <div><br>
                        </div>
                        <div>Best regards,</div>
                        <div>Yury.</div>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank" moz-do-not-send="true">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>