[OpenSIPS-Users] mid_registrar and vpn and nat

Alberto alberto.rinaudo at gmail.com
Tue Dec 13 23:50:30 UTC 2022


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
openvpn server: 172.172.0.2/24
opensips server: 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20221213/3dd80be0/attachment.html>


More information about the Users mailing list