<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><font class="Apple-style-span" face="'Courier New'"><div><div>Hi,</div><div><br></div><div>So I was experimenting with OpenSIPS 1.7.2 specifically with processing a PUBLISH request from a SIP UA that was being NAT'd (the client's source IP and Port were being NAT'd) and OpenSIPS is NOT aware of the NAT. &nbsp;The UA is normally connected to an Asterisk based PBX and doesn't normally have direct access to OpenSIPS (OS is used at the edge as an SBC)--so the PUBLISH to OpenSIPS is the only method the client UA uses to communicated with OpenSIPS directly. &nbsp;</div><div><br></div><div>So rather than try and deal with NAT in a more traditional OpenSIPS sort of way directly, I thought it might be super simple to just rewrite the received port ($rp) for the reply using the value of the original request's sender port ($sp) then send a reply back to the UA via t_reply. &nbsp;</div><div><br></div><div>It seems however that OpenSIPS does not want to reply back on the same port that the connection was received from by OpenSIPS (for example if source IP == 87.180.156.186 and source port = 1032, OpenSIPS should just send the 200 OK reply back to the same source IP and $rp port that I manually set? &nbsp;I doesn't seem to work instead OpenSIPS reply's back to the original $si but on port 5060 which I can only guess is coming from the port in the VIA or maybe contact headers?</div><div><br></div><div>Any suggestions or ideas of what I am doing wrong?</div><div><br></div><div>Here's my sample routing block:</div><div><br></div><div>route {</div><div>[snip]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (is_method("PUBLISH"))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "PUBLISH Received (sp): $sp");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "PUBLISH Received (rp): $rp");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rp = $sp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "PUBLISH Received (new rp): $rp");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route(2);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div>[snip]</div><div>}</div><div><br></div><div><div>route[2]</div><div>{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (!t_newtran())</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sl_reply_error();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(is_method("PUBLISH"))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "route[2] (rp): $rp");</div></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t_reply("200","PUBLISH RECEIVED");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div>}</div><div><br></div><div>Output from opensips.log:</div><div><br></div><div>Jul 25 14:36:02 HCVSBC01 /usr/sbin/opensips[9829]: PUBLISH Received (sp): 1032</div><div>Jul 25 14:36:02 HCVSBC01 /usr/sbin/opensips[9829]: PUBLISH Received (rp): 5060</div><div>Jul 25 14:36:02 HCVSBC01 /usr/sbin/opensips[9829]: PUBLISH Received (new rp): 1032</div><div>Jul 25 14:36:02 HCVSBC01 /usr/sbin/opensips[9829]: route[2] (rp): 1032</div></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">ngrep of the original SIP request and the OpenSIPS reply:</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">U 2013/07/25 14:36:02.875908 87.180.156.186:<b>1032</b> -&gt; 67.203.110.1:5060</font></div><div><font class="Apple-style-span" face="'Courier New'">PUBLISH <a href="sip:67.203.110.1:5060">sip:67.203.110.1:5060</a> SIP/2.0.</font></div><div><font class="Apple-style-span" face="'Courier New'">Via: SIP/2.0/UDP 192.168.253.82:<b>5060</b>;branch=z9hG4bK6a4204a58A1FFC74.</font></div><div><font class="Apple-style-span" face="'Courier New'">From: "555-1234" &lt;sip:</font><span class="Apple-style-span" style="font-family: 'Courier New'; ">1234567890AB</span><font class="Apple-style-span" face="'Courier New'">@sipserver.example.com&gt;;tag=634E87BF-917454FE.</font></div><div><font class="Apple-style-span" face="'Courier New'">To: &lt;<a href="sip:67.203.110.1:5060">sip:67.203.110.1:5060</a>&gt;.</font></div><div><font class="Apple-style-span" face="'Courier New'">CSeq: 1 PUBLISH.</font></div><div><font class="Apple-style-span" face="'Courier New'">Call-ID: <a href="mailto:ba064c2b-5bf79d8a-9dcaa451@192.168.253.82">ba064c2b-5bf79d8a-9dcaa451@192.168.253.82</a>.</font></div><div><font class="Apple-style-span" face="'Courier New'">Contact: &lt;<a href="sip:1234567890AB@192.168.253.82:">sip:1234567890AB@192.168.253.82:</a><b>5060</b>&gt;.</font></div><div><font class="Apple-style-span" face="'Courier New'">Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER.</font></div><div><font class="Apple-style-span" face="'Courier New'">Event: vq-rtcpxr.</font></div><div><font class="Apple-style-span" face="'Courier New'">User-Agent: PolycomSoundPointIP-SPIP_550-UA.</font></div><div><font class="Apple-style-span" face="'Courier New'">Accept-Language: en.</font></div><div><font class="Apple-style-span" face="'Courier New'">Max-Forwards: 70.</font></div><div><font class="Apple-style-span" face="'Courier New'">Expires: 3600.</font></div><div><font class="Apple-style-span" face="'Courier New'">Content-Type: application/vq-rtcpxr.</font></div><div><font class="Apple-style-span" face="'Courier New'">Content-Length: 628.</font></div><div><font class="Apple-style-span" face="'Courier New'">.</font></div><div><font class="Apple-style-span" face="'Courier New'">VQIntervalReport.</font></div><div><font class="Apple-style-span" face="'Courier New'">LocalMetrics:.</font></div><div><font class="Apple-style-span" face="'Courier New'">TimeStamps:START=2013-07-25T07:16:34Z STOP=2013-07-25T07:16:38Z.</font></div><div><font class="Apple-style-span" face="'Courier New'">SessionDesc:PT=0 PPS=50 SSUP=off.</font></div><div><font class="Apple-style-span" face="'Courier New'">CallID:4909416273d5f5fa506558eb523a386b@67.203.110.11:5060.</font></div><div><font class="Apple-style-span" face="'Courier New'">LocalAddr:IP=192.168.253.82 PORT=2224 SSRC=1941709243.</font></div><div><font class="Apple-style-span" face="'Courier New'">RemoteAddr:IP=67.203.110.11 PORT=14570 SSRC=330789935.</font></div><div><font class="Apple-style-span" face="'Courier New'">JitterBuffer:JBA=3 JBR=5 JBN=30 JBM=60 JBX=160.</font></div><div><font class="Apple-style-span" face="'Courier New'">PacketLoss:NLR=0.0 JDR=0.0.</font></div><div><font class="Apple-style-span" face="'Courier New'">BurstGapLoss:BLD=0.0 BD=0 GLD=0.0 GD=4710 GMIN=16.</font></div><div><font class="Apple-style-span" face="'Courier New'">Delay:RTD=0 ESD=61 IAJ=3.</font></div><div><font class="Apple-style-span" face="'Courier New'">Signal:RERL=127.</font></div><div><font class="Apple-style-span" face="'Courier New'">QualityEst:RLQ=93 RCQ=92 MOSLQ=4.1 MOSCQ=4.1.</font></div><div><font class="Apple-style-span" face="'Courier New'">DialogID:4909416273d5f5fa506558eb523a386b@67.203.110.11:5060;to-tag=as1516977a;from-tag=CED3BAF2-202B2F79.</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">U 2013/07/25 14:36:02.930303 67.203.110.1:5060 -&gt; 87.180.156.186:<b>5060</b></font></div><div><font class="Apple-style-span" face="'Courier New'">SIP/2.0 200 VQ PUBLISH RECEIVED.</font></div><div><font class="Apple-style-span" face="'Courier New'">Via: SIP/2.0/UDP 192.168.253.82:5060;received=87.180.156.186;branch=z9hG4bK6a4204a58A1FFC74.</font></div><div><font class="Apple-style-span" face="'Courier New'">From: "555-1234" &lt;sip:</font><span class="Apple-style-span" style="font-family: 'Courier New'; ">1234567890AB</span><font class="Apple-style-span" face="'Courier New'">@sipserver.example.com&gt;;tag=634E87BF-917454FE.</font></div><div><font class="Apple-style-span" face="'Courier New'">To: &lt;<a href="sip:67.203.110.1:5060">sip:67.203.110.1:5060</a>&gt;;tag=155c340f586c28d0300cf5a6ccf90d99-db4c.</font></div><div><font class="Apple-style-span" face="'Courier New'">CSeq: 1 PUBLISH.</font></div><div><font class="Apple-style-span" face="'Courier New'">Call-ID: <a href="mailto:ba064c2b-5bf79d8a-9dcaa451@192.168.253.82">ba064c2b-5bf79d8a-9dcaa451@192.168.253.82</a>.</font></div><div><font class="Apple-style-span" face="'Courier New'">Server: OpenSIPS.</font></div><div><font class="Apple-style-span" face="'Courier New'">Content-Length: 0.</font></div><div><font class="Apple-style-span" face="'Courier New'">.</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">Thanks in advance.</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">Cheers,</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">JPS</font></div></body></html>