<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body 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>
    &nbsp;&nbsp;&nbsp; if (src_ip==11.22.33.44) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # call from PBXes<br>
    &nbsp;&nbsp;&nbsp; } else {<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; # call from carriers<br>
    &nbsp;&nbsp;&nbsp; }<br>
    <br>
    Regards,<br>
    Bogdan<br>
    <br>
    On 03/15/2012 07:33 PM, Joshua Nankin wrote:
    <blockquote
cite="mid:CAAYWZ8nPjc8cVGeO5d2WA0DbjsfrkZw6jEN5XvQ2_M9UrxiJfA@mail.gmail.com"
      type="cite">Perfect! &nbsp;Thanks Bogdan, you're the man! &nbsp;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't work).
      <div>
        <br>
      </div>
      <div>One more question: I'm trying to use the same opensips box as
        an outbound proxy. &nbsp;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. &nbsp;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'm sure this involves creating another route, but I'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
              moz-do-not-send="true" href="mailto:bogdan@opensips.org">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("pub_IP") function (see&nbsp; <a
                moz-do-not-send="true"
                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 "alias = pub_IP" in your cfg (see <a
                moz-do-not-send="true"
                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 class="im"><br>
                <br>
                On 03/14/2012 10:54 PM, Joshua Nankin wrote: </div>
              <blockquote type="cite">
                <div class="im">Do I need to specify the public IPs of
                  my asterisk boxes in the load balancing table?
                  <div><br>
                  </div>
                  <div>Here'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 class="h5">
                    <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
                            moz-do-not-send="true"
                            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'm seeing that now. &nbsp;I just did a capture and
                          verified, the<br>
                          200s are coming out of my Asterisk box, and
                          OpenSIPS is relaying them<br>
                          properly. &nbsp;I'm not getting the ACK back from
                          my carrier. &nbsp;I'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 moz-do-not-send="true"
                                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. &nbsp;Here's what happens in
                              both the LB logs and Asterisk:<br>
                              &gt;&gt;<br>
                              &gt;&gt; Asterisk - <a
                                moz-do-not-send="true"
                                href="http://pastebin.com/"
                                target="_blank">http://pastebin.com/</a><br>
                              &gt;&gt; OpenSIPS - <a
                                moz-do-not-send="true"
                                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's quite a bit of logging<br>
                              &gt;&gt; happening for a pretty short
                              call. &nbsp;It seems that there's a<br>
                              &gt;&gt; retransmission problem here.
                              &nbsp;Also, I'm trying to negotiate T.38, so<br>
                              &gt;&gt; I'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 moz-do-not-send="true"
                                href="mailto:bogdan@opensips.org"
                                target="_blank">bogdan@opensips.org</a>&gt;

                              &nbsp;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. &nbsp;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. &nbsp;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
                              &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | 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; | &nbsp;1 | &nbsp; &nbsp; &nbsp; &nbsp;1 | <a
                                moz-do-not-send="true">sip:10.36.115.119</a>
                              | fax=300 &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 | tester<br>
                              &gt;&gt;&gt;&gt; &nbsp;|<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. &nbsp;I'm using
                              this for<br>
                              &gt;&gt;&gt;&gt; fax, so I have set the
                              resources field to 300 channels of "fax".
                              &nbsp; On<br>
                              &gt;&gt;&gt;&gt; my asterisk box, I've
                              added "outboundproxy=23.21.170.154", as
                              the 23.*<br>
                              &gt;&gt;&gt;&gt; IP is the external IP of
                              the opensips box. &nbsp;Below is my simple<br>
                              &gt;&gt;&gt;&gt; opensips.cfg that I've
                              adapted from the load balancing tutorial.
                              &nbsp;Any<br>
                              &gt;&gt;&gt;&gt; help would be much
                              appreciated. &nbsp;Additionally, for debugging
                              purposes,<br>
                              &gt;&gt;&gt;&gt; I've opened all UDP and
                              TCP ports. &nbsp;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="/usr/lib/opensips/modules/"<br>
                              &gt;&gt;&gt;&gt; loadmodule "maxfwd.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "sl.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "db_mysql.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "tm.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "uri.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "rr.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "dialog.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "mi_fifo.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "signaling.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule "textops.so"<br>
                              &gt;&gt;&gt;&gt; loadmodule
                              "load_balancer.so"<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam("mi_fifo",
                              "fifo_name", "/tmp/opensips_fifo")<br>
                              &gt;&gt;&gt;&gt; modparam("mi_fifo",
                              "fifo_mode",0666)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam("dialog",
                              "db_mode", 1)<br>
                              &gt;&gt;&gt;&gt; modparam("dialog",
                              "db_url",
                              "mysql://root:opensips@localhost/opensips")<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;
                              modparam("rr","enable_double_rr",1)<br>
                              &gt;&gt;&gt;&gt;
                              modparam("rr","append_fromtag",1)<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; modparam("load_balancer",<br>
                              &gt;&gt;&gt;&gt;
                              "db_url","mysql://root:opensips@localhost/opensips")<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; route{<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;if
                              (!mf_process_maxfwd_header("3")) {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;sl_send_reply("483","looping");<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;if (!has_totag())
                              {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # initial
                              request<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;record_route();<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;} else {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#
                              sequential request -&gt; &nbsp; &nbsp;obey Route
                              indication<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;loose_route();<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              t_relay();<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # handle cancel
                              and re-transmissions<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;if (
                              is_method("CANCEL") ) {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (
                              t_check_trans() )<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;t_relay();<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # from now on we
                              have only the initial requests<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; if
                              (!is_method("INVITE")) {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              send_reply("405","Method Not Allowed");<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # detect
                              resources and do balancing<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp;
                              &nbsp;load_balance("1","fax");<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # LB function
                              returns negative if no suitable
                              destination (for<br>
                              &gt;&gt;&gt;&gt; requested resources) is
                              found,<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # or if all
                              destinations are full<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; if
                              ($retcode&lt;0) {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;sl_send_reply("500","Service full");<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;xlog("Selected
                              destination is: $du\n");<br>
                              &gt;&gt;&gt;&gt;<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; # send it out<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;if (!t_relay()) {<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                              &nbsp;sl_reply_error();<br>
                              &gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
                              &gt;&gt;&gt;&gt; }<br>
                              &gt;&gt;&gt;&gt;<br>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
              <br>
              <div class="im">
                <pre cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" 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 class="moz-signature" cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
  </body>
</html>