Hi Deon,<br><br>I don&#39;t have experience doing what you&#39;re trying to doing. Only comment I have is that I doubt short-circuiting media-relay based upon SIP message source IPs is unlikely to work well.<br><br>Kennard<br>

<br><div class="gmail_quote">On Tue, Nov 2, 2010 at 11:17 PM, Deon Vermeulen <span dir="ltr">&lt;<a href="mailto:vermeulen.deon@gmail.com">vermeulen.deon@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Morning Kennard<br>
<br>
I really appreciate your feedback.<br>
<br>
I will be serving different networks, but will have control over most<br>
of them or at least be able to assist 3rd party vendors for those I<br>
don&#39;t.<br>
<br>
As for another NAT device behind the &quot;Main&quot; Firewall, there wouldn&#39;t<br>
be an issue like that, but would be a &quot;nice to have&quot; just in case I<br>
run into something like that.<br>
<br>
I think it would be best that I explain what I would like to achieve<br>
to clarify what my idea is:<br>
<br>
I have a Multi-Tenant solution running on Multiple Asterisk Servers.<br>
The solution currently works for customer that has an VPN/MPLS<br>
connection to me, but I would like to expand my services over the<br>
Internet for smaller customers who can not afford VPN/MPLS connections<br>
to me, but would like to make use of this service.<br>
I would also like to extend this service to have Follow me for my<br>
current customers via their mobile devices, from home, etc...<br>
The Multi-Tenant Asterisk Servers use one Database and handle all<br>
Media including Hunt groups, IVR, Speed Dials, Black/White listing,<br>
Connectivity to the PSTN via external Gateways, etc...<br>
I am looking at OpenSIPS to only help resolve the NAT issue and do<br>
Load-Balancing between my Asterisk Multi-Tenant servers.<br>
<br>
Hope this clarifies what I am looking to achieving.<br>
<br>
I would really appreciate your help with this.<br>
Perhaps a sample config of how you would do this would be awesome.<br>
<br>
Thanks again.<br>
<br>
Best Regards<br>
Deon<br>
<br>
<br>
So, I am looking at OpenSIPS to help provide LoadBalancing/Load<br>
Sharing between couple of Asterisk Servers, which will cut down a lot<br>
on expenses.<br>
<div><div></div><div class="h5"><br>
On 03 Nov 2010, at 5:26 AM, Kennard White wrote:<br>
<br>
&gt; Hi Deon,<br>
&gt;<br>
&gt; For better or worse there are many ways to configure opensips<br>
&gt; depending upon exactly what you are doing. Re your route6, it should<br>
&gt; be invoked from some branch route. One way branch routes are<br>
&gt; established is using t_on_branch(). Your route(3) (or somewhere)<br>
&gt; must be doing a lookup() and establish a branch route.<br>
&gt;<br>
&gt; As someone else said, a key question with what you&#39;re trying to do<br>
&gt; is: is your network an open or closed environment? If open<br>
&gt; environment (where you cannot control/know the networks where your<br>
&gt; users are) then non-ICE short-circuiting media relay will fail for<br>
&gt; people behind non-hairpinning firewalls or double firewalls. ICE<br>
&gt; (and yes, full ICE, not just STUN) is more robust way of avoiding<br>
&gt; media-relay when not needed. Of course, it has its own issues :-).<br>
&gt;<br>
&gt; Kennard<br>
&gt;<br>
&gt; On Tue, Nov 2, 2010 at 11:11 AM, Deon Vermeulen &lt;<a href="mailto:vermeulen.deon@gmail.com">vermeulen.deon@gmail.com</a><br>
&gt; &gt; wrote:<br>
&gt; Hi Kennard<br>
&gt;<br>
&gt; Thanks for the ideas.<br>
&gt; I really appreciate it.<br>
&gt;<br>
&gt; I got the config as an example from the Building Telephony systems<br>
&gt; with OpenSER.<br>
&gt; I choose the OpenSER implementation as it describes the implenetation<br>
&gt; of MediaProxy.<br>
&gt; Reason for choosing MediaProxy is because I am very, very interested<br>
&gt; in getting the ICE feature.<br>
&gt;<br>
&gt; I thought best to first get this config working before playing around<br>
&gt; with the ICE configuration.<br>
&gt;<br>
&gt; Could you be so kind and perhaps show me where I should call up<br>
&gt; route(6)?<br>
&gt;<br>
&gt; I use fully qualified domain names (i.e <a href="http://domaina.com" target="_blank">domaina.com</a>) for the domain.<br>
&gt; At the moment I specify the proxy with the IP of my Server as I<br>
&gt; haven&#39;t setup the DNS records yet.<br>
&gt;<br>
&gt; I really appreciate your feedback and assistance.<br>
&gt;<br>
&gt; Regards<br>
&gt; Deon<br>
&gt;<br>
&gt;<br>
&gt; On 02 Nov 2010, at 5:08 PM, Kennard White wrote:<br>
&gt;<br>
&gt; &gt; Hi Deon,<br>
&gt; &gt;<br>
&gt; &gt; Some ideas:<br>
&gt; &gt; 1. Capture the SIP traffic and see if media proxy is being invoked<br>
&gt; &gt; in the request and/or response (look for your P-hint messages), and<br>
&gt; &gt; the IP addresses.<br>
&gt; &gt; 2. Add xlog messages when you invoke mediarelay to confirm that they<br>
&gt; &gt; are getting called.<br>
&gt; &gt; 3. You&#39;re comparing $dd (which is a domain) to $si (which is an IP<br>
&gt; &gt; address). I don&#39;t think this will work in the general case, but<br>
&gt; &gt; maybe you&#39;re using IP addresses as your domains?<br>
&gt; &gt; 4. I don&#39;t see the code that invokes route(6) -- I assume that is in<br>
&gt; &gt; a branch_route not the request route?<br>
&gt; &gt;<br>
&gt; &gt; Good luck,<br>
&gt; &gt; Kennard<br>
&gt; &gt;<br>
&gt; &gt; On Tue, Nov 2, 2010 at 5:25 AM, Deon Vermeulen &lt;<a href="mailto:vermeulen.deon@gmail.com">vermeulen.deon@gmail.com</a><br>
&gt; &gt; &gt; wrote:<br>
&gt; &gt; Hi List<br>
&gt; &gt;<br>
&gt; &gt; I&#39;m trying to setup NAT to NOT use MediaProxy when it detects that 2<br>
&gt; &gt; devices are behind the same NAT Device, but rather have coms go<br>
&gt; &gt; directly between them.<br>
&gt; &gt; At the moment I can dial between the 2 phones and answer the call.<br>
&gt; &gt; The callee phone says &quot;Call Established&quot; upon answer, but the caller<br>
&gt; &gt; phone still says &quot;trying/connecting&quot;.<br>
&gt; &gt; I am sure this has something to do with my configuration, but I have<br>
&gt; &gt; &quot;NO IDEA&quot; where to start looking.<br>
&gt; &gt; The phones are setup to use their local IPs with no other STUN, ICE,<br>
&gt; &gt; or &quot;proxy like&quot; configurations.<br>
&gt; &gt; Below is a snipped from my opensips.cfg with the NAT configs and<br>
&gt; would<br>
&gt; &gt; really appreciate any help to get this working.<br>
&gt; &gt;<br>
&gt; &gt; modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
&gt; &gt; modparam(&quot;registrar&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
&gt; &gt; modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,   2)<br>
&gt; &gt; modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br>
&gt; &gt; modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1) # Use caching<br>
&gt; &gt; modparam(&quot;auth_db|usrloc|uri|avpops&quot;, &quot;use_domain&quot;, 1)<br>
&gt; &gt; modparam(&quot;auth_db|alias_db|domain|uri|uri_db|usrloc|permissions|<br>
&gt; &gt; siptrace|group|avpops|presence&quot;, &quot;db_url&quot;, &quot;mysql://<br>
&gt; &gt; opensips:opensipsrw@localhost/opensips&quot;)<br>
&gt; &gt; modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 10)<br>
&gt; &gt; modparam(&quot;nathelper&quot;, &quot;received_avp&quot;, &quot;$avp(i:42)&quot;)<br>
&gt; &gt; modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_socket&quot;, &quot;/var/run/mediaproxy-<br>
&gt; &gt; dispatcher.sock&quot;)<br>
&gt; &gt; modparam(&quot;mediaproxy&quot;, &quot;mediaproxy_timeout&quot;, 500)<br>
&gt; &gt; modparam(&quot;mi_datagram&quot;, &quot;socket_name&quot;, &quot;/var/run/opensips/<br>
&gt; &gt; opensips.sock&quot;)<br>
&gt; &gt; modparam(&quot;mi_datagram&quot;, &quot;children_count&quot;, 4)<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; # -------------------------  request routing logic<br>
&gt; &gt; ------------------- #<br>
&gt; &gt;<br>
&gt; &gt; route{<br>
&gt; &gt;<br>
&gt; &gt;     #<br>
&gt; &gt;     # -- 1 -- Request Validation<br>
&gt; &gt;     #<br>
&gt; &gt;     if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
&gt; &gt;         sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
&gt; &gt;         exit;<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     if (msg:len &gt;=  2048 ) {<br>
&gt; &gt;         sl_send_reply(&quot;513&quot;, &quot;Message too big&quot;);<br>
&gt; &gt;         exit;<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     #<br>
&gt; &gt;     # -- 2 -- Routing Preprocessing<br>
&gt; &gt;     #<br>
&gt; &gt;     ## Record-route all except Register<br>
&gt; &gt;     ## Mark packets with nat=yes<br>
&gt; &gt;     ## This mark will be used to identify the request in the loose<br>
&gt; &gt;     ## route section<br>
&gt; &gt;     if(!is_method(&quot;REGISTER&quot;)){<br>
&gt; &gt;         if(nat_uac_test(&quot;19&quot;)){<br>
&gt; &gt;             record_route(&quot;;nat=yes&quot;);<br>
&gt; &gt;         } else {<br>
&gt; &gt;             record_route();<br>
&gt; &gt;         }<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     ##Loose_route packets<br>
&gt; &gt;     if (has_totag()) {<br>
&gt; &gt;         #sequential request withing a dialog should<br>
&gt; &gt;         # take the path determined by record-routing<br>
&gt; &gt;         if (loose_route()) {<br>
&gt; &gt;             #Check authentication of re-invites<br>
&gt; &gt;             if(method==&quot;INVITE&quot;) {<br>
&gt; &gt;                 if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
&gt; &gt;                 proxy_challenge(&quot;&quot;,&quot;1&quot;);<br>
&gt; &gt;                 exit;<br>
&gt; &gt;             } else if (!db_check_from()) {<br>
&gt; &gt;                 sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
&gt; &gt;                 exit;<br>
&gt; &gt;             }<br>
&gt; &gt;         }<br>
&gt; &gt;                 ## BYE and CANCEL message handling<br>
&gt; &gt;         if(method==&quot;BYE&quot; || method==&quot;CANCEL&quot;) {<br>
&gt; &gt;             end_media_session();<br>
&gt; &gt;         }<br>
&gt; &gt;         ##Detect requests in the dialog behind NAT and flag with 6<br>
&gt; &gt;             if(nat_uac_test(&quot;19&quot;) || search(&quot;^Route:.*;nat=yes&quot;)){<br>
&gt; &gt;                 append_hf(&quot;P-hint: LR|fixcontact,setflag6,<br>
&gt; mediaproxy<br>
&gt; &gt; \r\n&quot;);<br>
&gt; &gt;                 fix_contact();<br>
&gt; &gt;                 setbflag(6);<br>
&gt; &gt;                 use_media_proxy();<br>
&gt; &gt;             }<br>
&gt; &gt;             route(1);<br>
&gt; &gt;         } else {<br>
&gt; &gt;             sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>
&gt; &gt;         }<br>
&gt; &gt;         exit;<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     #CANCEL processing<br>
&gt; &gt;     if (is_method(&quot;CANCEL&quot;)) {<br>
&gt; &gt;         if (t_check_trans()) {<br>
&gt; &gt;             end_media_session();<br>
&gt; &gt;             t_relay();<br>
&gt; &gt;         }<br>
&gt; &gt;         exit;<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     t_check_trans();<br>
&gt; &gt;<br>
&gt; &gt;     #<br>
&gt; &gt;     # -- 3 -- Determine Request Target<br>
&gt; &gt;     #<br>
&gt; &gt;     if (method==&quot;REGISTER&quot;) {<br>
&gt; &gt;         route(2);<br>
&gt; &gt;     } else {<br>
&gt; &gt;         route(3);<br>
&gt; &gt;     }<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; route[1] {<br>
&gt; &gt;     #<br>
&gt; &gt;     # -- 4 -- Forward request to target<br>
&gt; &gt;     #<br>
&gt; &gt;     # Forward statefully<br>
&gt; &gt;     t_on_reply(&quot;1&quot;);<br>
&gt; &gt;     t_on_failure(&quot;1&quot;);<br>
&gt; &gt;     if (!t_relay()) {<br>
&gt; &gt;         sl_reply_error();<br>
&gt; &gt;     }<br>
&gt; &gt;     exit;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; route[2] {<br>
&gt; &gt;     ## Register request handler<br>
&gt; &gt;     if (is_uri_host_local()) {<br>
&gt; &gt;         if (!www_authorize(&quot;&quot;, &quot;subscriber&quot;)) {<br>
&gt; &gt;             www_challenge(&quot;&quot;, &quot;1&quot;);<br>
&gt; &gt;             exit;<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt;         if (!db_check_to()) {<br>
&gt; &gt;             sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
&gt; &gt;             exit;<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt;            # Test to see if Caller is behind NAT<br>
&gt; &gt;         if(!search(&quot;^Contact:[ ]*\*&quot;) &amp;&amp; client_nat_test(&quot;7&quot;)) {<br>
&gt; &gt;             setbflag(6);<br>
&gt; &gt;             fix_nated_register();<br>
&gt; &gt;             force_rport();<br>
&gt; &gt;         }<br>
&gt; &gt;         save(&quot;location&quot;);<br>
&gt; &gt;         exit;<br>
&gt; &gt;<br>
&gt; &gt;     } else {<br>
&gt; &gt;         sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
&gt; &gt;     }<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; route[3] {<br>
&gt; &gt;     ## Requests handler<br>
&gt; &gt;     if (is_from_local()){<br>
&gt; &gt;         # From an internal domain -&gt; check the credentials and the<br>
&gt; &gt; FROM<br>
&gt; &gt;         #if(!allow_trusted()){<br>
&gt; &gt;             if (!proxy_authorize(&quot;&quot;,&quot;subscriber&quot;)) {<br>
&gt; &gt;                 proxy_challenge(&quot;&quot;,&quot;0&quot;);<br>
&gt; &gt;                 exit;<br>
&gt; &gt;             } else if(!db_check_from()) {<br>
&gt; &gt;             sl_send_reply(&quot;403&quot;, &quot;Forbidden, use From=ID&quot;);<br>
&gt; &gt;             exit;<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt;         if (client_nat_test(&quot;3&quot;)) {<br>
&gt; &gt;             append_hf(&quot;P-hint: route(3)|<br>
&gt; &gt; setflag7,forcerport,fix_contact\r\n&quot;);<br>
&gt; &gt;             setbflag(7);<br>
&gt; &gt;             force_rport();<br>
&gt; &gt;             fix_contact();<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt; ..............<br>
&gt; &gt;<br>
&gt; &gt; route[6] {<br>
&gt; &gt;     #<br>
&gt; &gt;     # -- NAT Traversal handling --<br>
&gt; &gt;     #<br>
&gt; &gt;     # Route[6] is the routing block responsible for activating the<br>
&gt; &gt; MediaProxy, whenever<br>
&gt; &gt;     # the caller or callee is behind NAT (flags 6 or 7<br>
&gt; respectively).<br>
&gt; &gt;     if (isbflagset(6) || isbflagset(7)) {<br>
&gt; &gt;            if ( $dd == $si ) {<br>
&gt; &gt;                    xlog(&quot;L_INFO&quot;, &quot;Both users behind same NAT, so we<br>
&gt; &gt; dont use MediaProxy\n&quot;);<br>
&gt; &gt;                    resetbflag(6);  # Unset NAT flag general.<br>
&gt; &gt;                    resetbflag(7);  # Unset NAT flag general.<br>
&gt; &gt;         } else<br>
&gt; &gt;         append_hf(&quot;P-hint: Route[6]: mediaproxy \r\n&quot;);<br>
&gt; &gt;         use_media_proxy();<br>
&gt; &gt;     }<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; .............<br>
&gt; &gt;<br>
&gt; &gt; onreply_route[1] {<br>
&gt; &gt; #<br>
&gt; &gt; #-- On-replay block routing --<br>
&gt; &gt; #<br>
&gt; &gt;     if (client_nat_test(&quot;1&quot;)) {<br>
&gt; &gt;         append_hf(&quot;P-hint: Onreply-route - fixcontact \r\n&quot;);<br>
&gt; &gt;         fix_contact();<br>
&gt; &gt;     }<br>
&gt; &gt;<br>
&gt; &gt;     if ((isbflagset(6) || isbflagset(7)) &amp;&amp; (status=~&quot;(180)|(183)|<br>
&gt; &gt; 2[0-9][0-9]&quot;)) {<br>
&gt; &gt;         if (search(&quot;^Content-Type:[ ]*application/sdp&quot;)) {<br>
&gt; &gt;             append_hf(&quot;P-hint: onreply_route|usemediaproxy \r\n&quot;);<br>
&gt; &gt;         use_media_proxy();<br>
&gt; &gt;         }<br>
&gt; &gt;     }<br>
&gt; &gt;     exit;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Thanks again for helping. Really appreciate it.<br>
&gt; &gt;<br>
&gt; &gt; Regards<br>
&gt; &gt; Deon<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Users mailing list<br>
&gt; &gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; &gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Users mailing list<br>
&gt; &gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; &gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
&gt; <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>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">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>
</div></div></blockquote></div><br>