This is a great thread, really full of answers and concepts for me atleast.<div>:)<br><br><div class="gmail_quote">On Mon, Jun 25, 2012 at 5:57 PM, Richard Brady <span dir="ltr">&lt;<a href="mailto:rnbrady@gmail.com" target="_blank">rnbrady@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Klaus / Daniel<br>
<br>
Thanks again for assistance with this.<br>
<br>
I&#39;ve tried the solution based on add_contact_alias() and<br>
handle_ruri_alias() and it works perfectly.<br>
<span class="HOEnZb"><font color="#888888"><br>
Richard<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 22 June 2012 13:47, Klaus Darilion &lt;<a href="mailto:klaus.mailinglists@pernau.at">klaus.mailinglists@pernau.at</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On 22.06.2012 13:50, Richard Brady wrote:<br>
&gt;&gt;<br>
&gt;&gt; Thanks guys, fantastic answers.<br>
&gt;&gt;<br>
&gt;&gt; You mention that NAT detection happens before save() and the flag is set<br>
&gt;&gt; by lookup() which makes much more sense. However, if Kamailio is not the<br>
&gt;&gt; registrar, as is the case with my current project, those functions are<br>
&gt;&gt; not called, so an alternative is needed. There are clearly several<br>
&gt;&gt; options.<br>
&gt;&gt;<br>
&gt;&gt; The solution I have gone for is to replace fix_nated_register() with<br>
&gt;&gt; fix_nated_contact() so that the REGISTER request is relayed with a<br>
&gt;&gt; modified Contact header containing the external ip:port of the client.<br>
&gt;<br>
&gt;<br>
&gt; The cleanest solution would be to use add_contact_alias() and<br>
&gt; handle_ruri_alias(). The do not change the contact but put the public<br>
&gt; address into a uri parameter. Thus, the URI seen by the client is always the<br>
&gt; one it sends:<br>
&gt; <a href="http://www.kamailio.org/docs/modules/3.2.x/modules_k/nathelper.html#id2550431" target="_blank">http://www.kamailio.org/docs/modules/3.2.x/modules_k/nathelper.html#id2550431</a><br>
&gt;<br>
&gt;<br>
&gt;&gt; That is then stored by the registrar (FreeSWITCH in my case) and used<br>
&gt;&gt; later to originate calls for that user. The FreeSWITCH know to send<br>
&gt;&gt; those calls to Kamailio through either use of the Path header and module<br>
&gt;&gt; in Kamailio, or through static configuration of fs_path or proxy<br>
&gt;&gt; parameters in FreeSWITCH.<br>
&gt;<br>
&gt;<br>
&gt; This is fine.<br>
&gt;<br>
&gt;<br>
&gt;&gt; The works for the first INVITE to the registered client behind NAT. But<br>
&gt;&gt; that client sends back a 200 OK with a Contact header containing its<br>
&gt;&gt; private IP address, and so fix_nated_contact() needs to be invoked on<br>
&gt;&gt; that response, and normally it would be due to FLB_NATB being set, but<br>
&gt;&gt; if Kamailio was not the registrar then that flag is not set. So I need<br>
&gt;&gt; to detect NAT on the client at the time of receiving the reply, or<br>
&gt;&gt; alternatively by having the registrar store a cookie and setting it<br>
&gt;&gt; based on that.<br>
&gt;<br>
&gt;<br>
&gt; You are correct. For in-dialog messages received from SIP clients I would<br>
&gt; always use add_contact_alias() and remove the NAT flags completely.<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; I suppose then my next question then is can I call nat_uac_test() on a<br>
&gt;&gt; UAS?<br>
&gt;<br>
&gt;<br>
&gt; Today, almost any SIP clients are SIP symmetric. This means, that they<br>
&gt; receive SIP from the some port/connection where they send. Thus, skip the<br>
&gt; NAT tests completely and always use add_contact_alias() for messages receive<br>
&gt; from SIP clients and handle_ruri_alias() for messages sent to SIP clients.<br>
&gt;<br>
&gt; Depending on if you use Freeswitch also as media relay you can also remove<br>
&gt; the media proxy stuff from the Kamailio config.<br>
&gt;<br>
&gt; On important thing is NAT-keep-alive. This is usually done by nathelper<br>
&gt; module by querying the location table for contact with NAT-flag set. Thus,<br>
&gt; either you do NAT keep-alive by freeswitch (e.g sending OPTIONS requests) or<br>
&gt; do it in your Kamailio proxy (e.g. set the nat_bflag<br>
&gt; <a href="http://www.kamailio.org/docs/modules/3.2.x/modules_k/usrloc.html#id2541477" target="_blank">http://www.kamailio.org/docs/modules/3.2.x/modules_k/usrloc.html#id2541477</a><br>
&gt; and call save(&quot;location&quot;,&quot;0x02&quot;) before relaying REGISTER to freeswitch.<br>
&gt; Then Kamailio will do NAT-pinging. Note, if you want to keep-alive only for<br>
&gt; successfully registered clients, you man want to call save() in the<br>
&gt; reply-route of the REGISTER request).<br>
&gt;<br>
&gt; regards<br>
&gt; Klaus<br>
<br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div></div></blockquote></div><br></div>