Hi Bogdan,<div>Thank you for reply, I tried to do as you recommended, I moved rewritehostport & force_send_socket into main routing block just before route(1); I do understand that I'm doing two RRs, but here'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><PUBLIC IP></b></font>.5068 > 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: <sip:10.22.10.254:5068;r2=on;lr=on;ftag=79557f47></div><div>Record-Route: <sip:<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b><PUBLIC IP></b></span>:5066;r2=on;lr=on;ftag=79557f47></div>
<div>Via: SIP/2.0/UDP 10.22.10.254:5068;branch=z9hG4bK8b37.90541a01.0</div><div>Via: SIP/2.0/UDP <PHONE IP>:6036;received=<PHONE IP>;branch=z9hG4bK-d87543-fe60ef3b8e5cdd4d-1--d87543-;rport=6036</div><div>Max-Forwards: 69</div>
<div>Contact: <sip:6000@<PHONE IP>:6036></div><div>To: <sip:555@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b><PUBLIC IP></b></span>:5066></div><div>From: "User"<sip:6000@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b><PUBLIC IP></b></span>:5066>;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 <PHONE IP></div><div>s=eyeBeam</div><div>c=IN IP4 <PHONE IP></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 > 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><PUBLIC IP></b></span></div><div>Via: SIP/2.0/UDP <PHONE IP>:6036;received=<PHONE IP>;branch=z9hG4bK-d87543-fe60ef3b8e5cdd4d-1--d87543-;rport=6036</div>
<div>From: "User"<sip:6000@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b><PUBLIC IP></b></span>:5066>;tag=79557f47</div><div>To: <sip:555@<span class="Apple-style-span" style="color: rgb(204, 0, 0); "><b><PUBLIC IP></b></span>:5066>;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="asterisk", nonce="1e41babb"</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><PUBLIC IP></b></span>.5068 > 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"><<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>></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) < OpenSIPS > Private IP (eth1) <------> Private IP (eth0) Asterisk.<br>
<br>
I'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 & public ones. It all works fine on SIP layer, I do understand that I also need RTP proxy, but at this stage I'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("<a href="http://10.22.10.1:6000" target="_blank">10.22.10.1:6000</a> <<a href="http://10.22.10.1:6000/" target="_blank">http://10.22.10.1:6000/</a>>");<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'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> <<a href="http://10.22.10.254:5068/" target="_blank">http://10.22.10.254:5068/</a>><div><div></div><div class="h5"><br>
<br>
####### Modules Section ########<br>
<br>
#set module path<br>
mpath="/opt/opensips/lib64/opensips/modules/"<br>
<br>
loadmodule "signaling.so"<br>
loadmodule "sl.so"<br>
loadmodule "tm.so"<br>
loadmodule "rr.so"<br>
loadmodule "maxfwd.so"<br>
loadmodule "textops.so"<br>
loadmodule "mi_fifo.so"<br>
loadmodule "uri.so"<br>
<br>
# ----------------- setting module-specific parameters ---------------<br>
<br>
# ----- mi_fifo params -----<br>
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")<br>
<br>
# ----- rr params -----<br>
# add value to ;lr param to cope with most of the UAs<br>
modparam("rr", "enable_full_lr", 1)<br>
modparam("rr", "append_fromtag", 1)<br>
<br>
# ----- uri params -----<br>
modparam("uri", "use_uri_table", 0)<br>
<br>
####### Routing Logic ########<br>
<br>
# main request routing logic<br>
<br>
route{<br>
<br>
if (!mf_process_maxfwd_header("10")) {<br>
sl_send_reply("483","Too Many Hops");<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("BYE")) {<br>
setflag(1); # do accounting ...<br>
setflag(3); # ... even if the transaction fails<br>
} else if (is_method("INVITE")) {<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("ACK") ) {<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 -><br>
# ignore and discard<br>
exit;<br>
}<br>
}<br>
sl_send_reply("404","Not here");<br>
}<br>
exit;<br>
}<br>
<br>
#initial requests<br>
<br>
# CANCEL processing<br>
if (is_method("CANCEL"))<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("L_ERR",<br>
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");<br>
if (!is_method("ACK"))<br>
sl_send_reply("403","Preload Route denied");<br>
exit;<br>
}<br>
<br>
record_route();<br>
route(1);<br>
}<br>
<br>
<br>
route[1] {<br></div></div>
rewritehostport("<a href="http://10.22.10.1:6000" target="_blank">10.22.10.1:6000</a> <<a href="http://10.22.10.1:6000/" target="_blank">http://10.22.10.1:6000/</a>>");<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>