Thanks for your help.<br><br>Since I&#39;m using OpenSER 1.1 I believe that nat_bflag isn&#39;t supported in userloc module for 1.1. <br>But you got me on the right track:<br><br>onreply_route[2]<br>{<br><br>if(status=~&quot;(180)|(183)|2[0-9][0-9]&quot;)<br>
{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isflagset(6) || nat_uac_test(&quot;1&quot;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlog(&quot;L_INFO&quot;, &quot;FANN NAT - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fix_nated_contact();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use_media_proxy();<br>}<br><br><br>exit;<br><br>}<br><br>This worked for me. Thank you very much for your help.<br><br><br><br><br><div class="gmail_quote">On Mon, May 26, 2008 at 6:28 PM, Höskuldur &lt;<a href="mailto:hoskuldur@gmail.com">hoskuldur@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi<br><br>I have two user clients behind separate NAT networks. My OpenSER is directly connected to the Internet and has it&#39;s own external IP address.<br>
<br>Both clients are using STUN to get their external IP address and correct port for SIP messages.<br>
<br>They successfully register with Openser, which is using Nathelper module and Mediaproxy.<br><br>In this case, since the client is behind NAT, it puts the wrong port in the Contact field of a SIP message.<br><br>As a result, SOME SIP messages from OpenSER are never received by the client.<br>

<br>But with the help of Nathelper, OpenSER should correct the port in Contact field, by replacing the NAT port with the src port of a SIP message (UDP pack).<br><br>The problem is, that it looks like OpenSER only corrects the port in Contact field for client A (The one who initiates the call) but not Client B(The one who&#39;s called).<br>

<br>For a better explaination, please check out my logs from ngrep.<br><br><br>CLIENT A to OPENSER<br><br>U 2008/05/26 16:53:26.285586 <a href="http://157.157.78.173:54182" target="_blank">157.157.78.173:54182</a> -&gt; <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a><br>

INVITE <a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a> SIP/2.0.<br>From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>
To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261023.<br>Contact: 1006&lt;<a href="http://sip:1006@157.157.78.173:62356" target="_blank">sip:1006@157.157.78.173:62356</a>&gt;. !!!NB!!! &lt;-- This is the WRONG reply port.<br>

<br>OPENSER RELAYS TO CLIENT B<br><br>U 2008/05/26 16:53:26.301864 <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a> -&gt; <a href="http://130.208.183.251:49211" target="_blank">130.208.183.251:49211</a><br>
INVITE <a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a> SIP/2.0.<br>
Record-Route: &lt;sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes&gt;.<br>From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>

To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;.<br>Via: SIP/2.0/UDP <a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;branch=z9hG4bK5db1.ce9aea2.0;rport.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;rport=54182;branch=z9hG4bKc0a8150a10007e0026261023.<br>
Contact: 1006&lt;<a href="http://sip:1006@157.157.78.173:54182" target="_blank">sip:1006@157.157.78.173:54182</a>&gt;. !!!NB!!! &lt;-- OpenSER detects it and changes it to correct reply port. Works great.<br><br>CLIENT B ANSWERS TO OPENSER<br>

<br>U 2008/05/26 16:53:27.301368 <a href="http://130.208.183.251:49211" target="_blank">130.208.183.251:49211</a> -&gt; <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a><br>SIP/2.0 200 OK.<br>From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>

To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;;tag=10007900-26261046.<br>Via: SIP/2.0/UDP <a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;branch=z9hG4bK5db1.ce9aea2.0.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261023.<br>
Contact: 1001&lt;<a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a>&gt;. !!!NB!!! &lt;-- Now lets try Client B. Wrong reply port.<br><br>OPENSER TO CLIENT A<br><br>U 2008/05/26 16:53:27.305241 <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a> -&gt; <a href="http://157.157.78.173:54182" target="_blank">157.157.78.173:54182</a><br>

SIP/2.0 200 OK.<br>From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;;tag=10007900-26261046.<br>

Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261023.<br>Contact: 1001&lt;<a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a>&gt;. !!!NB!!! &lt;-- OpenSER didn&#39;t change the port like before, so now Client B never receives ACK from Client A.<br>

<br>CLIENT A TO OPENSER<br><br>U 2008/05/26 16:53:27.518621 <a href="http://157.157.78.173:54182" target="_blank">157.157.78.173:54182</a> -&gt; <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a><br>
ACK <a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a> SIP/2.0.<br>
From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;;tag=10007900-26261046.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261505.<br>
Contact: 1006&lt;<a href="http://sip:1006@157.157.78.173:62356" target="_blank">sip:1006@157.157.78.173:62356</a>&gt;.<br>Route: &lt;sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes&gt;.<br>
<br>OPENSER TO CLIENT B<br>
<br>U 2008/05/26 16:53:27.519192 <a href="http://212.50.206.33:5060" target="_blank">212.50.206.33:5060</a> -&gt; <a href="http://130.208.183.251:49208" target="_blank">130.208.183.251:49208</a>&nbsp; !!!NB!!! &lt;-- OpenSER sends to the WRONG port!<br>
ACK <a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a> SIP/2.0.<br>
Record-Route: &lt;sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes&gt;.<br>From: 1006&lt;<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>&gt;;tag=10007500-26260f5b.<br>

To: &lt;<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>&gt;;tag=10007900-26261046.<br>CSeq: 101 ACK.<br>Via: SIP/2.0/UDP <a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;branch=z9hG4bK5db1.ce9aea2.2;rport.<br>

Via: SIP/2.0/UDP 157.157.78.173:62356;rport=54182;branch=z9hG4bKc0a8150a10007e0026261505.<br><br><br>This last ACK message is never received by Client B because the client isn&#39;t listening on port 49208.<br>If I manually use rewriteport(&quot;49211&quot;) it works, because obviously this last package is then forced to port 49211 which the client listening on.<br>

<br>Also, the first line in my main route is force_rport(); but that still doesn&#39;t do it.<br><br>I&#39;ve been struggling with this problem for a few weeks now so all comments and suggestions are very welcome.<br><br>

My OpenSER config file can be found here: <a href="http://hoski.public.is/openser.cfg" target="_blank">http://hoski.public.is/openser.cfg</a><br><br>Best regards,<br><font color="#888888">Höskuldur<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><br>Kveðja, Höskuldur