Sorry about that - I have a Gmail keyboard shortcut reflex :)<div><br></div><div>So, I&#39;d like to do a regex based check where the PBXes all have addresses starting with 10.*.  I did the following:</div><div><br></div><div>


<div>                if (src_ip !~ &quot;^10\..*&quot;){</div><div>                        if (!load_balance(&quot;1&quot;,&quot;fax&quot;,&quot;1&quot;)) {</div><div>                                sl_send_reply(&quot;503&quot;,&quot;Service Unavailable&quot;);</div>


<div>                                exit;</div><div>                        }</div><div>                }</div></div><div>                else {</div><div>                          # this is an outgoing call, just let the packets go through (somehow)</div>

<div>                }</div><div><br></div><div>But it looks like my regex is not working and incoming calls get a busy signal.  To make matters worse, I tried debugging with:</div><div><br></div><div>1. log(src_ip)</div>

<div>2. log(&quot;source ip: &quot; + src_ip)</div><div>3. log($si)</div><div>4. log(&quot;source_ip: $si&quot;)</div><div><br></div><div>None of those works (all produce config file syntax errors except for 4 which just prints out the actual $si characters.  Why can&#39;t I do the above?</div>

<div><br></div><div>Finally, what do I need to do in the &quot;else&quot; block to let the outgoing call packets go through?  I tried placing an outgoing call with out the load_balancing block, but my packets were not relayed from opensips to the carrier.</div>

<div><br></div><div>Thanks,</div><div>Josh </div><div><br><div class="gmail_quote">On Thu, Mar 15, 2012 at 1:34 PM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<u></u>

  
    
  
  <div bgcolor="#ffffff" text="#000000">
    Hi Joshua,<br>
    <br>
    Please keep the list at CC - whatever we talk here, should also be
    to the benefit of the entire opensips community ;)<br>
    <br>
    So, to detect where the call comes from, you simply check the source
    at IP level:<br>
        if (src_ip==11.22.33.44) {<br>
               # call from PBXes<br>
        } else {<br>
               # call from carriers<br>
        }<br>
    <br>
    Regards,<br>
    Bogdan<div><div><br>
    <br>
    On 03/15/2012 07:33 PM, Joshua Nankin wrote:
    <blockquote type="cite">Perfect!  Thanks Bogdan, you&#39;re the man!  I was having
      some trouble with record_route_preset because I was including the
      port in the IP string as well (I had seen others do this in alias,
      so I just copied that in the record_route_preset function and
      things still didn&#39;t work).
      <div>
        <br>
      </div>
      <div>One more question: I&#39;m trying to use the same opensips box as
        an outbound proxy.  Now, since I automatically load balance any
        INVITEs, when I place an outgoing call, the call is routed right
        back to one of my Asterisk machines.  How would I tell if the
        request is incoming (and then load balance it) or outgoing (and
        then relay the messages outside of the network).</div>
      <div><br>
      </div>
      <div>I&#39;m sure this involves creating another route, but I&#39;m a
        complete n00b when it comes to opensips - I just started messing
        around with it this week.</div>
      <div><br>
      </div>
      <div>Thanks again for your help!<br>
        <br>
        <div class="gmail_quote">On Thu, Mar 15, 2012 at 4:40 AM,
          Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</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">
            <div bgcolor="#ffffff" text="#000000"> Hi Joshua,<br>
              <br>
              Ok, I see - your opensips is actually in a private
              network.<br>
              What you can do is to use instead of record_route() the
              record_route_preset(&quot;pub_IP&quot;) function (see  <a href="http://www.opensips.org/html/docs/modules/1.7.x/rr.html#id250439" target="_blank">http://www.opensips.org/html/docs/modules/1.7.x/rr.html#id250439</a>)
              - this will make opensips to advertise in RR the public
              IP. Additionally set &quot;alias = pub_IP&quot; in your cfg (see <a href="http://www.opensips.org/Resources/DocsCoreFcn17#toc26" target="_blank">http://www.opensips.org/Resources/DocsCoreFcn17#toc26</a>),
              so that opensips will recognize its own pub IP in the
              Route hdr (in ACK)<br>
              <br>
              Regards,<br>
              Bogdan
              <div><br>
                <br>
                On 03/14/2012 10:54 PM, Joshua Nankin wrote: </div>
              <blockquote type="cite">
                <div>Do I need to specify the public IPs of
                  my asterisk boxes in the load balancing table?
                  <div><br>
                  </div>
                  <div>Here&#39;s is what my carrier told me:</div>
                  <div><br>
                  </div>
                  <div><span>After looking into this issue further, it
                      appears you are not including the Record-route
                      header for your public IP address. The reason the
                      call is failing currently is because you have
                      listed your internal IP address for us to send the
                      call too, however since we do not have access to
                      your internal IP address, we are unable to send
                      this to you. You can see this in the 200 OK that
                      you send to us, where you start with your internal
                      IP, and go straight to our IP.</span></div>
                  <div><font color="#500050" face="arial, sans-serif"><br>
                    </font></div>
                  <div><font color="#500050" face="arial, sans-serif">You
                      can find a packet captures for the call here:</font></div>
                  <div><font color="#500050" face="arial, sans-serif"><br>
                    </font></div>
                </div>
                <div><font color="#500050" face="arial, sans-serif">Capture
                    from OpenSIPS: xxxxxxxxxxxxxx</font></div>
                <div><span style="color:rgb(80,0,80);font-family:arial,sans-serif">Capture from Asterisk:
                    xxxxxxxxxxxxxx</span></div>
                <div>
                  <div>
                    <div><font color="#500050" face="arial, sans-serif"><br>
                      </font></div>
                    <div><font color="#500050" face="arial, sans-serif">Thanks,</font></div>
                    <div><font color="#500050" face="arial, sans-serif">Josh<br>
                      </font><br>
                      <div class="gmail_quote"> On Wed, Mar 14, 2012 at
                        1:02 PM, Joshua Nankin <span dir="ltr">&lt;<a href="mailto:jnankin@gmail.com" target="_blank">jnankin@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"> Yeah,
                          I&#39;m seeing that now.  I just did a capture and
                          verified, the<br>
                          200s are coming out of my Asterisk box, and
                          OpenSIPS is relaying them<br>
                          properly.  I&#39;m not getting the ACK back from
                          my carrier.  I&#39;m going to<br>
                          check with them and send the capture files I
                          just generated - they use<br>
                          IP whitelists, and this may just be a
                          authentication/security problem.<br>
                          <br>
                          Thanks again!<br>
                          <br>
                          -Josh<br>
                          <br>
                          On Wed, Mar 14, 2012 at 12:59 PM,
                          Bogdan-Andrei Iancu<br>
                          <div>
                            <div>&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;

                              wrote:<br>
                              &gt; Hi Joshua,<br>
                              &gt;<br>
                              &gt; It seams to be a lot of 200 OK
                              retransmissions from Asterisk because
                              there<br>
                              &gt; is no ACK from the original caller
                              side.<br>
                              &gt;<br>
                              &gt; Do you see the caller sending such
                              ACK ? have you tried to make a network<br>
                              &gt; capture ?<br>
                              &gt;<br>
                              &gt; Regards,<br>
                              &gt; Bogdan<br>
                              &gt;<br>
                              &gt;<br>
                              &gt;<br>
                              &gt; On 03/14/2012 06:27 PM, Joshua Nankin
                              wrote:<br>
                              &gt;&gt;<br>
                              &gt;&gt; Hey Bogdan!<br>
                              &gt;&gt;<br>
                              &gt;&gt; So, it appears that the call gets
                              to the LB and is forwarded to<br>
                              &gt;&gt; Asterisk.  Here&#39;s what happens in
                              both the LB logs and Asterisk:<br>
                              &gt;&gt;<br>
                              &gt;&gt; Asterisk - <a href="http://pastebin.com/" target="_blank">http://pastebin.com/</a><br>
                              &gt;&gt; OpenSIPS - <a href="http://pastebin.com/" target="_blank">http://pastebin.com/</a><br>
                              &gt;&gt;<br>
                              &gt;&gt;<br>
                              &gt;&gt; I have debug=6 on OpenSIPS, so
                              there&#39;s quite a bit of logging<br>
                              &gt;&gt; happening for a pretty short
                              call.  It seems that there&#39;s a<br>
                              &gt;&gt; retransmission problem here.
                               Also, I&#39;m trying to negotiate T.38, so<br>
                              &gt;&gt; I&#39;m not sure if that has
                              something to do with this.<br>
                              &gt;&gt;<br>
                              &gt;&gt; Thanks,<br>
                              &gt;&gt; Josh<br>
                              &gt;&gt;<br>
                              &gt;&gt; On Wed, Mar 14, 2012 at 7:25 AM,
                              Bogdan-Andrei Iancu<br>
                              &gt;&gt; &lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;

                               wrote:<br>
                              &gt;&gt;&gt;<br>
                              &gt;&gt;&gt; Hi Joshua,<br>
                              &gt;&gt;&gt;<br>
                              &gt;&gt;&gt; Have you checked (at network
                              level) if the actual call (the inbound
                              one,<br>
                              &gt;&gt;&gt; from a client) gets to
                              opensips LB ? and if so, if the call gets<br>
                              &gt;&gt;&gt; forwarded<br>
                              &gt;&gt;&gt; to Asterisk ?<br>
                              &gt;&gt;&gt;<br>
                              &gt;&gt;&gt; Regards,<br>
                              &gt;&gt;&gt; Bogdan<br>
                              &gt;&gt;&gt;<br>
                              &gt;&gt;&gt;<br>
                              &gt;&gt;&gt; On 03/13/2012 10:00 PM,
                              Joshua Nankin wrote:<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; Hello,<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; Trying to use OpenSIPS as
                              both a load balancer for incoming calls
                              and<br>
                              &gt;&gt;&gt;&gt; as an outbound proxy to
                              my carrier.  I have been unsuccessful to
                              place<br>
                              &gt;&gt;&gt;&gt; outgoing or incoming
                              calls, and I think I just need some help
                              with the<br>
                              &gt;&gt;&gt;&gt; configuration.  Just for
                              testing, I have one Asterisk box behind<br>
                              &gt;&gt;&gt;&gt; OpenSIPS and the load
                              balancer table on OpenSIPS looks like
                              this:<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
+----+----------+-------------------+-----------+------------+-------------+<br>
                              &gt;&gt;&gt;&gt; | id | group_id | dst_uri
                                        | resources | probe_mode |<br>
                              &gt;&gt;&gt;&gt; description<br>
                              &gt;&gt;&gt;&gt; |<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
+----+----------+-------------------+-----------+------------+-------------+<br>
                              &gt;&gt;&gt;&gt; |  1 |        1 | <a>sip:10.36.115.119</a>
                              | fax=300   |          0 | tester<br>
                              &gt;&gt;&gt;&gt;  |<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
+----+----------+-------------------+-----------+------------+-------------+<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; The dst_ur is the
                              internal IP of my asterisk box.  I&#39;m using
                              this for<br>
                              &gt;&gt;&gt;&gt; fax, so I have set the
                              resources field to 300 channels of &quot;fax&quot;.
                                On<br>
                              &gt;&gt;&gt;&gt; my asterisk box, I&#39;ve
                              added &quot;outboundproxy=23.21.170.154&quot;, as
                              the 23.*<br>
                              &gt;&gt;&gt;&gt; IP is the external IP of
                              the opensips box.  Below is my simple<br>
                              &gt;&gt;&gt;&gt; opensips.cfg that I&#39;ve
                              adapted from the load balancing tutorial.
                               Any<br>
                              &gt;&gt;&gt;&gt; help would be much
                              appreciated.  Additionally, for debugging
                              purposes,<br>
                              &gt;&gt;&gt;&gt; I&#39;ve opened all UDP and
                              TCP ports.  Still not able to connect.<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; debug=6<br>
                              &gt;&gt;&gt;&gt; memlog=1<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; fork=yes<br>
                              &gt;&gt;&gt;&gt; children=2<br>
                              &gt;&gt;&gt;&gt; log_stderror=yes<br>
                              &gt;&gt;&gt;&gt; log_facility=LOG_LOCAL0<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; disable_tcp=yes<br>
                              &gt;&gt;&gt;&gt; disable_dns_blacklist =
                              yes<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; auto_aliases=no<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; check_via=no<br>
                              &gt;&gt;&gt;&gt; dns=off<br>
                              &gt;&gt;&gt;&gt; rev_dns=off<br>
                              &gt;&gt;&gt;&gt; port=5060<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
                              mpath=&quot;/usr/lib/opensips/modules/&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;maxfwd.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;sl.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;db_mysql.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;tm.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;uri.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;rr.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;dialog.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;mi_fifo.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;signaling.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule &quot;textops.so&quot;<br>
                              &gt;&gt;&gt;&gt; loadmodule
                              &quot;load_balancer.so&quot;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam(&quot;mi_fifo&quot;,
                              &quot;fifo_name&quot;, &quot;/tmp/opensips_fifo&quot;)<br>
                              &gt;&gt;&gt;&gt; modparam(&quot;mi_fifo&quot;,
                              &quot;fifo_mode&quot;,0666)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam(&quot;dialog&quot;,
                              &quot;db_mode&quot;, 1)<br>
                              &gt;&gt;&gt;&gt; modparam(&quot;dialog&quot;,
                              &quot;db_url&quot;,
                              &quot;mysql://root:opensips@localhost/opensips&quot;)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
                              modparam(&quot;rr&quot;,&quot;enable_double_rr&quot;,1)<br>
                              &gt;&gt;&gt;&gt;
                              modparam(&quot;rr&quot;,&quot;append_fromtag&quot;,1)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam(&quot;load_balancer&quot;,<br>
                              &gt;&gt;&gt;&gt;
                              &quot;db_url&quot;,&quot;mysql://root:opensips@localhost/opensips&quot;)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; route{<br>
                              &gt;&gt;&gt;&gt;        if
                              (!mf_process_maxfwd_header(&quot;3&quot;)) {<br>
                              &gt;&gt;&gt;&gt;              
                               sl_send_reply(&quot;483&quot;,&quot;looping&quot;);<br>
                              &gt;&gt;&gt;&gt;                exit;<br>
                              &gt;&gt;&gt;&gt;        }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;        if (!has_totag())
                              {<br>
                              &gt;&gt;&gt;&gt;                 # initial
                              request<br>
                              &gt;&gt;&gt;&gt;              
                               record_route();<br>
                              &gt;&gt;&gt;&gt;        } else {<br>
                              &gt;&gt;&gt;&gt;                #
                              sequential request -&gt;    obey Route
                              indication<br>
                              &gt;&gt;&gt;&gt;              
                               loose_route();<br>
                              &gt;&gt;&gt;&gt;                
                              t_relay();<br>
                              &gt;&gt;&gt;&gt;                 exit;<br>
                              &gt;&gt;&gt;&gt;         }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;         # handle cancel
                              and re-transmissions<br>
                              &gt;&gt;&gt;&gt;        if (
                              is_method(&quot;CANCEL&quot;) ) {<br>
                              &gt;&gt;&gt;&gt;                if (
                              t_check_trans() )<br>
                              &gt;&gt;&gt;&gt;                      
                               t_relay();<br>
                              &gt;&gt;&gt;&gt;                exit;<br>
                              &gt;&gt;&gt;&gt;        }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;         # from now on we
                              have only the initial requests<br>
                              &gt;&gt;&gt;&gt;         if
                              (!is_method(&quot;INVITE&quot;)) {<br>
                              &gt;&gt;&gt;&gt;                
                              send_reply(&quot;405&quot;,&quot;Method Not Allowed&quot;);<br>
                              &gt;&gt;&gt;&gt;                 exit;<br>
                              &gt;&gt;&gt;&gt;         }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;         # detect
                              resources and do balancing<br>
                              &gt;&gt;&gt;&gt;      
                               load_balance(&quot;1&quot;,&quot;fax&quot;);<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;         # LB function
                              returns negative if no suitable
                              destination (for<br>
                              &gt;&gt;&gt;&gt; requested resources) is
                              found,<br>
                              &gt;&gt;&gt;&gt;         # or if all
                              destinations are full<br>
                              &gt;&gt;&gt;&gt;         if
                              ($retcode&lt;0) {<br>
                              &gt;&gt;&gt;&gt;            
                               sl_send_reply(&quot;500&quot;,&quot;Service full&quot;);<br>
                              &gt;&gt;&gt;&gt;              exit;<br>
                              &gt;&gt;&gt;&gt;         }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;        xlog(&quot;Selected
                              destination is: $du\n&quot;);<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;         # send it out<br>
                              &gt;&gt;&gt;&gt;        if (!t_relay()) {<br>
                              &gt;&gt;&gt;&gt;              
                               sl_reply_error();<br>
                              &gt;&gt;&gt;&gt;        }<br>
                              &gt;&gt;&gt;&gt; }<br>
                              &gt;&gt;&gt;&gt;<br>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
              <br>
              <div>
                <pre cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
  </div></div></div>

</blockquote></div><br></div>