[OpenSIPS-Users] mid_registrar and vpn and nat

Bogdan-Andrei Iancu bogdan at opensips.org
Tue Jan 3 18:26:47 UTC 2023


Hi Alberto,

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.

Best regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
OpenSIPS Bootcamp 5-16 Dec 2022, online
   https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/

On 12/14/22 1:50 AM, Alberto wrote:
> Hi,
> I have a problem with a vpn setup, not really nat, or maybe it's nat...
>
> The setup I have is:
> Phone - openvpn - opensips - public internet - asterisk
>
> openvpn subnet: 10.0.0.0/24 <http://10.0.0.0/24>
> openvpn server: 172.172.0.2/24 <http://172.172.0.2/24>
> opensips server: 172.172.0.10/24 <http://172.172.0.10/24>
>
> In my configuration I have:
>
> loadmodule "mid_registrar.so"
> modparam("mid_registrar", "max_contacts", 1)
> modparam("mid_registrar", "mode", 0)
> modparam("mid_registrar", "received_avp", "$avp(rcv)")
> modparam("mid_registrar", "tcp_persistent_flag", 
> "TCP_PERSIST_REGISTRATIONS")
>
> if (nat_uac_test(119)) {
>   setbflag("NAT");
>   if (is_method("REGISTER")) {
>     fix_nated_register();
>   } else {
>     fix_nated_contact();
>   }
> }
>
> if (is_method("REGISTER")) {
>   mid_registrar_save("location", "p0");
>   .....
> }
>
> if ($(tu{uri.param,ctid}) != NULL && mid_registrar_lookup("location")) {
>   if (!t_relay()) {
>     send_reply(500, "Internal Error");
>   }
> }
>
> So, when the phone sends a REGISTER to opensips, the contact header 
> contains the private ip of the vpn (10.0.0.X/24).
> fix_nated_register is able to detect that the ip in the contact is 
> different from the source ip and sets the received avp.
> 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.
> 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.
> It should instead contain the openvpn server ip (172.172.0.2), that 
> could then route the call to the phone.
>
> I tried to change $rd manually, but that just breaks routing for ACK 
> messages.
> What am I doing wrong?
>
> Thanks
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20230103/7e8834df/attachment.html>


More information about the Users mailing list