<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">Hi Alberto,<br>
      <br>
      Yes, in the registration record the Contact URI is kept as
      received and the "fixed" src IP is stored into the "received"
      field. Upon lookup the contact URI goes into RURI (as you
      observed) and the "received" goes into dst_uri (destination URI)
      or $du. When OpenSIPS relays, the $du takes precedence to the $ru,
      the requests goes to the right destination.<br>
      <br>
      Best regards,<br>
    </font>
    <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 Bootcamp 5-16 Dec 2022, online
  <a class="moz-txt-link-freetext" href="https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/">https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/</a></pre>
    <div class="moz-cite-prefix">On 12/14/22 1:50 AM, Alberto wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANoA6_+p1-pveQs1dOjDkrfnoYifgJLyTgmcOAXUtyHwq6fLTA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hi,</div>
        <div>I have a problem with a vpn setup, not really nat, or maybe
          it's nat...</div>
        <div><br>
        </div>
        <div>The setup I have is:</div>
        <div>Phone - openvpn - opensips - public internet - asterisk<br>
          <br>
        </div>
        <div>openvpn subnet: <a href="http://10.0.0.0/24"
            moz-do-not-send="true">10.0.0.0/24</a><br>
        </div>
        <div>openvpn server: <a href="http://172.172.0.2/24"
            moz-do-not-send="true">172.172.0.2/24</a><br>
        </div>
        <div>opensips server: <a href="http://172.172.0.10/24"
            moz-do-not-send="true">172.172.0.10/24</a><br>
        </div>
        <div><br>
        </div>
        <div>In my configuration I have:<br>
        </div>
        <div><br>
        </div>
        <div>loadmodule "mid_registrar.so"  <br>
          modparam("mid_registrar", "max_contacts", 1)<br>
          modparam("mid_registrar", "mode", 0)<br>
          modparam("mid_registrar", "received_avp", "$avp(rcv)")<br>
          modparam("mid_registrar", "tcp_persistent_flag",
          "TCP_PERSIST_REGISTRATIONS")</div>
        <div><br>
        </div>
        <div>if (nat_uac_test(119)) {<br>
            setbflag("NAT");<br>
            if (is_method("REGISTER")) {<br>
              fix_nated_register();<br>
            } else {<br>
              fix_nated_contact();<br>
            }<br>
          }</div>
        <div><br>
        </div>
        <div>if (is_method("REGISTER")) {<br>
            mid_registrar_save("location", "p0");<br>
        </div>
        <div>  .....</div>
        <div>}</div>
        <div><br>
        </div>
        <div>if ($(tu{uri.param,ctid}) != NULL &&
          mid_registrar_lookup("location")) {<br>
            if (!t_relay()) {<br>
              send_reply(500, "Internal Error");<br>
            }</div>
        <div>}<br>
        </div>
        <div><br>
        </div>
        <div>So, when the phone sends a REGISTER to opensips, the
          contact header contains the private ip of the vpn
          (10.0.0.X/24).</div>
        <div>fix_nated_register is able to detect that the ip in the
          contact is different from the source ip and sets the received
          avp.</div>
        <div>But if I do opensips-cli -x mi ul_dump, I see that the
          contact still contains the openvpn ip, and the received field
          contains the correct openvpn ip.</div>
        <div>This is a problem because when I do the
          mid_registrar_lookup, $ru is set to the contact, which
          contains an ip that the opensips server is not aware of.</div>
        <div>It should instead contain the openvpn server ip
          (172.172.0.2), that could then route the call to the phone.</div>
        <div><br>
        </div>
        <div>I tried to change $rd manually, but that just breaks
          routing for ACK messages.</div>
        <div>What am I doing wrong?</div>
        <div><br>
        </div>
        <div>Thanks<br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>