Hi Bogdan,<div>Thank you for reply, I tried to do as you recommended, I moved rewritehostport &amp; force_send_socket into main routing block just before route(1); I do understand that I&#39;m doing two RRs, but here&#39;s TCPdump of the softphone trying to Invite, notice that these are packets from OpenSIPS to Asterisk, and they use Public IP to send SIP packets to internal Private IP:</div>
<div><br></div><div><div>00:10:05.942128 IP <font class="Apple-style-span" color="#CC0000"><b>&lt;PUBLIC IP&gt;</b></font>.5068 &gt; 10.22.10.1.6000: UDP, length 961</div><div>.PV.k..PV.s...E.....@.@...w...</div><div>.</div>
<div>INVITE <a href="http://sip:555@10.22.10.1:6000">sip:555@10.22.10.1:6000</a> SIP/2.0</div><div>Record-Route: &lt;sip:10.22.10.254:5068;r2=on;lr=on;ftag=79557f47&gt;</div><div>Record-Route: &lt;sip:<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>:5066;r2=on;lr=on;ftag=79557f47&gt;</div>
<div>Via: SIP/2.0/UDP 10.22.10.254:5068;branch=z9hG4bK8b37.90541a01.0</div><div>Via: SIP/2.0/UDP &lt;PHONE IP&gt;:6036;received=&lt;PHONE IP&gt;;branch=z9hG4bK-d87543-fe60ef3b8e5cdd4d-1--d87543-;rport=6036</div><div>Max-Forwards: 69</div>
<div>Contact: &lt;sip:6000@&lt;PHONE IP&gt;:6036&gt;</div><div>To: &lt;sip:555@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>:5066&gt;</div><div>From: &quot;User&quot;&lt;sip:6000@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>:5066&gt;;tag=79557f47</div>
<div>Call-ID: 927d4958c229b528@Zmxhc2g.</div><div>CSeq: 1 INVITE</div><div>Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO</div><div>Content-Type: application/sdp</div><div>Supported: eventlist</div>
<div>User-Agent: eyeBeam release 3015c stamp 27107</div><div>Content-Length: 190</div><div><br></div><div>v=0</div><div>o=- 3069147771 3069148115 IN IP4 &lt;PHONE IP&gt;</div><div>s=eyeBeam</div><div>c=IN IP4 &lt;PHONE IP&gt;</div>
<div>t=0 0</div><div>m=audio 8306 RTP/AVP 8 18 101</div><div>a=fmtp:101 0-15</div><div>a=rtpmap:101 telephone-event/8000</div><div>a=sendrecv</div><div><br></div><div><br></div><div>Then, Asterisk replies using private IPs:</div>
<div><br></div><div>00:10:05.942717 IP 10.22.10.1.6000 &gt; 10.22.10.254.5068: UDP, length 637</div><div>.PV.s..PV.k...E...E...@.</div><div>.</div><div>.</div><div>.</div><div>.</div><div>..p....k7SIP/2.0 407 Proxy Authentication Required</div>
<div>Via: SIP/2.0/UDP 10.22.10.254:5068;branch=z9hG4bK8b37.90541a01.0;received=<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span></div><div>Via: SIP/2.0/UDP &lt;PHONE IP&gt;:6036;received=&lt;PHONE IP&gt;;branch=z9hG4bK-d87543-fe60ef3b8e5cdd4d-1--d87543-;rport=6036</div>
<div>From: &quot;User&quot;&lt;sip:6000@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>:5066&gt;;tag=79557f47</div><div>To: &lt;sip:555@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>:5066&gt;;tag=as0b8e2c25</div>
<div>Call-ID: 927d4958c229b528@Zmxhc2g.</div><div>CSeq: 1 INVITE</div><div>User-Agent: Asterisk PBX</div><div>Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO</div><div>Supported: replaces</div><div>
Proxy-Authenticate: Digest algorithm=MD5, realm=&quot;asterisk&quot;, nonce=&quot;1e41babb&quot;</div><div>Content-Length: 0</div><div><br></div><div><br></div><div>And then OpenSIPS responds from Public IP again:</div><div>
<br></div><div>00:10:05.944903 IP <span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b>&lt;PUBLIC IP&gt;</b></span>.5068 &gt; 10.22.10.1.6000: UDP, length 353</div><div><br></div><br><div class="gmail_quote">
2010/12/7 Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Yuri,<div class="im"><br>
<br>
Yuri Kirsanov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi community,<br>
<br>
I have following setup:<br>
<br>
Public IP (eth0) &lt; OpenSIPS &gt; Private IP (eth1) &lt;------&gt; Private IP (eth0) Asterisk.<br>
<br>
I&#39;m trying to relay all the initial packets received by OpenSIPS to Asterisk, so I record-route initial packets and process all responses using loose routing. OpenSIPS is restricted to use only two UDP IP addresses - private &amp; public ones. It all works fine on SIP layer, I do understand that I also need RTP proxy, but at this stage I&#39;ve got strange problem - with mhomed=1 in configuration file OpenSIPS still sends packets using public IP address, while Contact, To and Via fields are set correctly, to private IP address of OpenSIPS.<br>

</blockquote></div>
OpenSIPS does not changes Contact and To IPs when forwarding a request.....are you sure you see such changes???<br>
<br>
The only IPs that reflects the used interface are the VIA and Record-Route...Actually in your case (if interface changing is done), you should have 2 RR headers...<br>
<br>
Also, using mhomed and force_send_socket() in the same time is a bit redundant - they do the same : setting the outgoing interface for the request:<br>
   - mhomed is doing autodetection based on destination IP<br>
   - force_send_socket() is setting the inteface from script.<br>
<br>
BTW, it is bogus to do:<br>
       rewritehostport(&quot;<a href="http://10.22.10.1:6000" target="_blank">10.22.10.1:6000</a> &lt;<a href="http://10.22.10.1:6000/" target="_blank">http://10.22.10.1:6000/</a>&gt;&quot;);<div class="im"><br>
       force_send_socket(10.22.10.254);<br>
<br></div>
in route[1] as this route is a generic relay route used also for sending sequential requests.....put that lines in main route just where you do record_route().<br>
<br>
Regards,<br>
Bogdan<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
I have tried to use force_send_socket but without any luck. Could you please help me with this configuration? At least - why does OpenSIPS uses public IP? Thanks!<br>
<br>
Here&#39;s my configuration:<br>
<br>
####### Global Parameters #########<br>
log_facility=LOG_LOCAL4<br>
fork=yes<br>
children=4<br>
debug=9<br>
disable_tcp=yes<br>
auto_aliases=no<br>
mhomed=1<br>
port=5066<br>
listen=udp:XXX.XXX.XXX.XXX:5066<br></div>
listen=udp:<a href="http://10.22.10.254:5068" target="_blank">10.22.10.254:5068</a> &lt;<a href="http://10.22.10.254:5068/" target="_blank">http://10.22.10.254:5068/</a>&gt;<div><div></div><div class="h5"><br>
<br>
####### Modules Section ########<br>
<br>
#set module path<br>
mpath=&quot;/opt/opensips/lib64/opensips/modules/&quot;<br>
<br>
loadmodule &quot;signaling.so&quot;<br>
loadmodule &quot;sl.so&quot;<br>
loadmodule &quot;tm.so&quot;<br>
loadmodule &quot;rr.so&quot;<br>
loadmodule &quot;maxfwd.so&quot;<br>
loadmodule &quot;textops.so&quot;<br>
loadmodule &quot;mi_fifo.so&quot;<br>
loadmodule &quot;uri.so&quot;<br>
<br>
# ----------------- setting module-specific parameters ---------------<br>
<br>
# ----- mi_fifo params -----<br>
modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/opensips_fifo&quot;)<br>
<br>
# ----- rr params -----<br>
# add value to ;lr param to cope with most of the UAs<br>
modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 1)<br>
<br>
# ----- uri params -----<br>
modparam(&quot;uri&quot;, &quot;use_uri_table&quot;, 0)<br>
<br>
####### Routing Logic ########<br>
<br>
# main request routing logic<br>
<br>
route{<br>
<br>
        if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
                sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
                exit;<br>
        }<br>
<br>
        if (has_totag()) {<br>
                # sequential request withing a dialog should<br>
                # take the path determined by record-routing<br>
                if (loose_route()) {<br>
                        if (is_method(&quot;BYE&quot;)) {<br>
                                setflag(1); # do accounting ...<br>
                                setflag(3); # ... even if the transaction fails<br>
                        } else if (is_method(&quot;INVITE&quot;)) {<br>
                                # even if in most of the cases is useless, do RR for<br>
                                # re-INVITEs alos, as some buggy clients do change route set<br>
                                # during the dialog.<br>
                                record_route();<br>
                        }<br>
                        # route it out to whatever destination was set by loose_route()<br>
                        # in $du (destination URI).<br>
                        route(1);<br>
                } else {<br>
                         if ( is_method(&quot;ACK&quot;) ) {<br>
                                if ( t_check_trans() ) {<br>
                                        # non loose-route, but stateful ACK; must be an ACK after<br>
                                        # a 487 or e.g. 404 from upstream server<br>
                                        t_relay();<br>
                                        exit;<br>
                                } else {<br>
                                        # ACK without matching transaction -&gt;<br>
                                        # ignore and discard<br>
                                        exit;<br>
                                }<br>
                        }<br>
                        sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>
                }<br>
                exit;<br>
        }<br>
<br>
        #initial requests<br>
<br>
        # CANCEL processing<br>
        if (is_method(&quot;CANCEL&quot;))<br>
        {<br>
                if (t_check_trans())<br>
                        t_relay();<br>
                exit;<br>
        }<br>
<br>
        t_check_trans();<br>
<br>
        # preloaded route checking<br>
        if (loose_route()) {<br>
                xlog(&quot;L_ERR&quot;,<br>
                &quot;Attempt to route with preloaded Route&#39;s [$fu/$tu/$ru/$ci]&quot;);<br>
                if (!is_method(&quot;ACK&quot;))<br>
                        sl_send_reply(&quot;403&quot;,&quot;Preload Route denied&quot;);<br>
                exit;<br>
        }<br>
<br>
        record_route();<br>
        route(1);<br>
}<br>
<br>
<br>
route[1] {<br></div></div>
        rewritehostport(&quot;<a href="http://10.22.10.1:6000" target="_blank">10.22.10.1:6000</a> &lt;<a href="http://10.22.10.1:6000/" target="_blank">http://10.22.10.1:6000/</a>&gt;&quot;);<div class="im"><br>
        force_send_socket(10.22.10.254);<br>
        if (!t_relay()) {<br>
                sl_reply_error();<br>
        };<br>
        exit;<br>
}<br></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
  <br>
</blockquote>
<br>
<br>
-- <br>
Bogdan-Andrei Iancu<br>
OpenSIPS Bootcamp<br>
15 - 19 November 2010, Edison, New Jersey, USA<br>
<a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br></div>