Re: Kamailio as a Stateless Smart SIP Proxy

Antonio via sr-users <[email protected]>
Newsgroups gmane.comp.voip.ser
Message-ID <CAFgS45ty0QmnUo=xzJ2mrhaV6Bpx1Bn5qv7zJ5QDNE5rQhY1cQ@mail.gmail.com>
route[REGISTER] {
if (!is_method("REGISTER")) return;
if (nat_uac_test("19")) {
xlog("L_INFO", "NAT detected for REGISTER request\n");
fix_nated_contact();
msg_apply_changes();
}
encode_contact("proxy_ip", ADV_HOST);
t_relay();
exit;
}


I have found this but ima little bit confused that i have to use
msg_apply_changes();
before doing encode_contact()
because otherwise kama respond that buffer is overloded





On Fri, Jul 18, 2025 at 9:31 AM Ihor Olkhovskyi via sr-users <
[email protected]> wrote:

>
> https://www.kamailio.org/docs/modules/5.0.x/modules/nathelper.html#nathelper.f.fix_nated_contact
> ? With combination of alias and other parameter, means you can store full
> original contact header (encoded) in a Contact params as well.
> Yes, it brakes RFC, but you can handle it manually
>
> Le lun. 14 juil. 2025 à 14:36, Antonio via sr-users <
> [email protected]> a écrit :
>
>> BUT
>> When Kamailio forwards REGISTER to Upstream(Asterisk), it will  contain
>> the REAL IP of the UAC
>>
>> so later if someone will dial  UAC it will not path through  Kamailio
>>
>> On Sat, Jul 12, 2025 at 9:32 PM Alex Balashov via sr-users <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> Yes, that's exactly what those functions enable.
>>>
>>> When you receive the REGISTER request, you use set_contact_alias() /
>>> add_contact_alias() to add an `;alias` parameter to the Contact, which
>>> reflects the client's external IP/port/transport. You then pass that
>>> REGISTER request onto the registrar.
>>>
>>> When you get an incoming request from the registrar to the client, you
>>> use handle_ruri_alias() to read the `;alias` parameter and load the
>>> IP/port/transport values into the destination set ($du), while stripping
>>> the `;alias` parameter off the RURI. You then t_relay() the request, which
>>> will follow $du to the next hop read from the `;alias` parameter.
>>>
>>> -- Alex
>>>
>>> > On Jul 11, 2025, at 4:28 PM, Antonio <[email protected]> wrote:
>>> >
>>> > Thanks for the reply
>>> >
>>> > I want to use Kamailio as a proxy, but a smart one.
>>> > It doesn't store anything, but:
>>> > • Modifies REGISTER requests → adds the client's IP/port to Contact
>>> > • So when the PBX sends an INVITE back, Kamailio reads this data from
>>> the R-URI and forwards the call to the client
>>> >
>>> > Hope it makes sense.
>>> >
>>> >
>>> > On Fri, Jul 11, 2025 at 10:14 PM Alex Balashov via sr-users <
>>> [email protected]> wrote:
>>> > Hi,
>>> >
>>> > The set_contact_alias() / handle_ruri_alias() functions from the
>>> `nathelper` module[1] are quite ready-made for this use-case, though you
>>> may need a more sophisticated approach if the upstream registrar does not
>>> support Path[2][3].
>>> >
>>> > -- Alex
>>> >
>>> > [1] https://kamailio.org/docs/modules/6.0.x/modules/nathelper.html
>>> >
>>> > [2] https://datatracker.ietf.org/doc/html/rfc3327
>>> >
>>> > [3]
>>> https://kamailio.org/docs/modules/6.0.x/modules/path.html#path.f.add_path
>>> >
>>> > > On Jul 11, 2025, at 6:19 AM, Antonio via sr-users <
>>> [email protected]> wrote:
>>> > >
>>> > > Hi everyone,
>>> > > Do we have a ready-to-use Kamailio role or configuration for:
>>> > >
>>> > > “Kamailio as a Stateless Smart SIP Proxy”,
>>> > > Specifically one that uses Contact Header Encoding?
>>> > >
>>> > > That is — a proxy where Kamailio does not store registration state,
>>> > > but encodes the client’s IP and port into the Contact header during
>>> REGISTER,
>>> > > and later decodes it from the INVITE to forward the call back to the
>>> client.
>>> > > Thanks in advance!
>>> > > --
>>> > >
>>> > > Antony
>>> > > [email protected]
>>> > > __________________________________________________________
>>> > > Kamailio - Users Mailing List - Non Commercial Discussions --
>>> [email protected]
>>> > > To unsubscribe send an email to [email protected]
>>> > > Important: keep the mailing list in the recipients, do not reply
>>> only to the sender!
>>> >
>>> > --
>>> > Alex Balashov
>>> > Principal Consultant
>>> > Evariste Systems LLC
>>> > Web: https://evaristesys.com, https://www.csrpswitch.com
>>> > Tel: +1-706-510-6800
>>> >
>>> > __________________________________________________________
>>> > Kamailio - Users Mailing List - Non Commercial Discussions --
>>> [email protected]
>>> > To unsubscribe send an email to [email protected]
>>> > Important: keep the mailing list in the recipients, do not reply only
>>> to the sender!
>>> >
>>> >
>>> > --
>>> >
>>> > Antony
>>> > [email protected]
>>>
>>> --
>>> Alex Balashov
>>> Principal Consultant
>>> Evariste Systems LLC
>>> Web: https://evaristesys.com, https://www.csrpswitch.com
>>> Tel: +1-706-510-6800
>>>
>>> __________________________________________________________
>>> Kamailio - Users Mailing List - Non Commercial Discussions --
>>> [email protected]
>>> To unsubscribe send an email to [email protected]
>>> Important: keep the mailing list in the recipients, do not reply only to
>>> the sender!
>>>
>>
>>
>> --
>>
>> *Antony*
>> [email protected]
>>
>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions --
>> [email protected]
>> To unsubscribe send an email to [email protected]
>> Important: keep the mailing list in the recipients, do not reply only to
>> the sender!
>>
>
>
> --
> Best regards,
> Ihor (Igor)
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions --
> [email protected]
> To unsubscribe send an email to [email protected]
> Important: keep the mailing list in the recipients, do not reply only to
> the sender!
>


-- 

*Antony*
[email protected]

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.