Thanks for your help.<br><br>Since I'm using OpenSER 1.1 I believe that nat_bflag isn'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=~"(180)|(183)|2[0-9][0-9]")<br>
{<br> if (isflagset(6) || nat_uac_test("1"))<br> {<br> xlog("L_INFO", "FANN NAT - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");<br> fix_nated_contact();<br>
}<br> 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 <<a href="mailto:hoskuldur@gmail.com">hoskuldur@gmail.com</a>> 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'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'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> -> <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<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>
To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261023.<br>Contact: 1006<<a href="http://sip:1006@157.157.78.173:62356" target="_blank">sip:1006@157.157.78.173:62356</a>>. !!!NB!!! <-- 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> -> <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: <sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes>.<br>From: 1006<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>
To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>.<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<<a href="http://sip:1006@157.157.78.173:54182" target="_blank">sip:1006@157.157.78.173:54182</a>>. !!!NB!!! <-- 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> -> <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<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>
To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>;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<<a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a>>. !!!NB!!! <-- 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> -> <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<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>;tag=10007900-26261046.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261023.<br>Contact: 1001<<a href="http://sip:1001@130.208.183.251:49208" target="_blank">sip:1001@130.208.183.251:49208</a>>. !!!NB!!! <-- OpenSER didn'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> -> <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<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>;tag=10007900-26261046.<br>
Via: SIP/2.0/UDP 157.157.78.173:62356;branch=z9hG4bKc0a8150a10007e0026261505.<br>
Contact: 1006<<a href="http://sip:1006@157.157.78.173:62356" target="_blank">sip:1006@157.157.78.173:62356</a>>.<br>Route: <sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes>.<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> -> <a href="http://130.208.183.251:49208" target="_blank">130.208.183.251:49208</a> !!!NB!!! <-- 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: <sip:<a href="http://212.50.206.33" target="_blank">212.50.206.33</a>;lr;ftag=10007500-26260f5b;nat=yes>.<br>From: 1006<<a href="mailto:sip%3A1006@212.50.206.33" target="_blank">sip:1006@212.50.206.33</a>>;tag=10007500-26260f5b.<br>
To: <<a href="mailto:sip%3A1001@212.50.206.33" target="_blank">sip:1001@212.50.206.33</a>>;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't listening on port 49208.<br>If I manually use rewriteport("49211") 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't do it.<br><br>I'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