[SR-Users] logging destination IP and proto on reponse

Sergiu Pojoga pojogas at gmail.com
Thu Jan 3 16:07:58 CET 2019


Like I said, via[2] will not be accurate if the original request came from
behind NAT, as VIA[2] in most cases will be a private IP (provided UAC
didn't perform any far-end NAT-traversal tricks).

The final destination of a reply will be decided upon performing routing on
the reply message, taking into account *rport *and *received* values in the
VIA headers.

That being said, I don't know the true answer, but very interested to find
out as well.

On Thu, Jan 3, 2019 at 9:34 AM Andrew Chen <achen at fuze.com> wrote:

> First, thanks guys for all the responses.  These are great suggestions.
>
> So my Kamailio needs to forward SIP responses back to ether client or
> server side, depending on where the initial SIP method originated from.
> Client side generally is behind NAT.  When forwarding the response, I want
> to log the destination IP to I'm forwarding it to and which protocol it is
> using by using some sort of pseudovariable.  The reason I want to do this
> is for troubleshooting purposes to show that Kamailio is sending it where
> it suppose to send it.
>
> After trying different options, I actually ended up using the Via header
> to log where the responses are sending it back to:
>
> $sel(via[2].host) - destination host
> $sel(via[2].transport - protocol to use
>
> Note that I'm not sure if this is the best and accurate option for what
> I'm doing, but I'm using this assuming the fact that my next hop is in
> via[2].
>
> On Thu, Jan 3, 2019 at 4:53 AM Daniel-Constantin Mierla <miconda at gmail.com>
> wrote:
>
>> Hello,
>>
>> like Joel said, in reply_rpute or onreply_route use $si and $pr to get
>> the source ip and protocol of the reply.
>>
>> If you need it in failure_route, then use $T_rpl($si) and $T_rpl($pr),
>> from the TMX module like was suggested by another response.
>>
>> If none of these is what you want, then explain where you needed to see
>> what is possible.
>>
>> Cheers,
>> Daniel
>>
>> On Thu, Jan 3, 2019 at 7:06 AM YAS0 CANER <caner_yaso at hotmail.com> wrote:
>>
>>> Oh my bad, I got now.
>>>
>>> on reply route , you can get some variables. Have you tried "TMX module
>>> Pseudo-Variables"
>>> https://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables
>>> ------------------------------
>>> *From:* sr-users <sr-users-bounces at lists.kamailio.org> on behalf of
>>> YAS0 CANER <caner_yaso at hotmail.com>
>>> *Sent:* Thursday, January 3, 2019 9:01 AM
>>> *To:* Sergiu Pojoga; Kamailio (SER) - Users Mailing List
>>> *Subject:* Re: [SR-Users] logging destination IP and proto on reponse
>>>
>>> Hello,
>>>
>>> you can use accounting module to log them.You can append new variables,
>>>
>>> modparam("acc", "log_extra",
>>> "src_user=$fU;src_domain=$fd;src_ip=$si;"
>>> "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
>>> in addition, there is a onsend_route to help what you need.
>>>
>>> https://www.kamailio.org/wiki/cookbooks/5.2.x/core#onsend_route
>>> cookbooks:5.2.x:core [Kamailio SIP Server Wiki]
>>> <https://www.kamailio.org/wiki/cookbooks/5.2.x/core#onsend_route>
>>> This is the second section of the configuration file, containing the
>>> directives to load modules and set their parameters. It contains the
>>> directives loadmodule and modparam.In the default configuration file starts
>>> with the line setting the path to modules (the assignment to mpath core
>>> parameter.. Example of content:
>>> www.kamailio.org
>>>
>>>
>>> onsend_route
>>>
>>>   onsend_route {
>>>     if(to_ip==1.2.3.4 && !isflagset(12)){
>>>       log <http://www.opengroup.org/onlinepubs/009695399/functions/log.html>(1, "message blocked\n");
>>>       drop;
>>>     }
>>>   }
>>>
>>>
>>>
>>> ------------------------------
>>> *From:* sr-users <sr-users-bounces at lists.kamailio.org> on behalf of
>>> Sergiu Pojoga <pojogas at gmail.com>
>>> *Sent:* Thursday, January 3, 2019 4:01 AM
>>> *To:* Kamailio (SER) - Users Mailing List
>>> *Subject:* Re: [SR-Users] logging destination IP and proto on reponse
>>>
>>> $sel(via[2].host) should give the 'destination' of the reply, provided
>>> that the original request wasn't from behind NAT and one single proxy in
>>> between UAs.
>>>
>>> Don't take my answer for granted, as I don't think it's complete and/or
>>> accurate.
>>>
>>>
>>> On Wed, Jan 2, 2019 at 5:11 PM Andrew Chen <achen at fuze.com> wrote:
>>>
>>> Hey all,
>>>
>>> Any way to log destination IP and proto of SIP responses?  I'd tried to
>>> use majority of the pseudovars, but they all just return <null>.
>>>
>>> Thanks.
>>>
>>> --
>>> Andy Chen
>>> achen@ <achen at thinkingphones.com>fuze.com
>>>
>>>
>>> *Confidentiality Notice: The information contained in this e-mail and any
>>> attachments may be confidential. If you are not an intended recipient,
>>> you
>>> are hereby notified that any dissemination, distribution or copying of
>>> this
>>> e-mail is strictly prohibited. If you have received this e-mail in error,
>>> please notify the sender and permanently delete the e-mail and any
>>> attachments immediately. You should not retain, copy or use this e-mail
>>> or
>>> any attachment for any purpose, nor disclose all or any part of the
>>> contents to any other person. Thank you.*
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>
>>
>> --
>> Daniel-Constantin Mierla - http://www.asipto.com
>> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>
>
> --
> Andy Chen
> Sr. Telephony Lead Engineer
> 415 516 5535 (M)
> achen@ <achen at thinkingphones.com>fuze.com
>
>
> *Confidentiality Notice: The information contained in this e-mail and any
> attachments may be confidential. If you are not an intended recipient, you
> are hereby notified that any dissemination, distribution or copying of this
> e-mail is strictly prohibited. If you have received this e-mail in error,
> please notify the sender and permanently delete the e-mail and any
> attachments immediately. You should not retain, copy or use this e-mail or
> any attachment for any purpose, nor disclose all or any part of the
> contents to any other person. Thank you.*
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190103/fc81ac82/attachment.html>


More information about the sr-users mailing list