Sorry about that - I have a Gmail keyboard shortcut reflex :)<div><br></div><div>So, I'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 !~ "^10\..*"){</div><div> if (!load_balance("1","fax","1")) {</div><div> sl_send_reply("503","Service Unavailable");</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("source ip: " + src_ip)</div><div>3. log($si)</div><div>4. log("source_ip: $si")</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't I do the above?</div>
<div><br></div><div>Finally, what do I need to do in the "else" 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"><<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>></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'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't work).
<div>
<br>
</div>
<div>One more question: I'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'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"><<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>></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 <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 "alias = pub_IP" 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'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"><<a href="mailto:jnankin@gmail.com" target="_blank">jnankin@gmail.com</a>></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. 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'm not getting the ACK back from
my carrier. 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><<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>>
wrote:<br>
> Hi Joshua,<br>
><br>
> It seams to be a lot of 200 OK
retransmissions from Asterisk because
there<br>
> is no ACK from the original caller
side.<br>
><br>
> Do you see the caller sending such
ACK ? have you tried to make a network<br>
> capture ?<br>
><br>
> Regards,<br>
> Bogdan<br>
><br>
><br>
><br>
> On 03/14/2012 06:27 PM, Joshua Nankin
wrote:<br>
>><br>
>> Hey Bogdan!<br>
>><br>
>> So, it appears that the call gets
to the LB and is forwarded to<br>
>> Asterisk. Here's what happens in
both the LB logs and Asterisk:<br>
>><br>
>> Asterisk - <a href="http://pastebin.com/" target="_blank">http://pastebin.com/</a><br>
>> OpenSIPS - <a href="http://pastebin.com/" target="_blank">http://pastebin.com/</a><br>
>><br>
>><br>
>> I have debug=6 on OpenSIPS, so
there's quite a bit of logging<br>
>> happening for a pretty short
call. It seems that there's a<br>
>> retransmission problem here.
Also, I'm trying to negotiate T.38, so<br>
>> I'm not sure if that has
something to do with this.<br>
>><br>
>> Thanks,<br>
>> Josh<br>
>><br>
>> On Wed, Mar 14, 2012 at 7:25 AM,
Bogdan-Andrei Iancu<br>
>> <<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>>
wrote:<br>
>>><br>
>>> Hi Joshua,<br>
>>><br>
>>> Have you checked (at network
level) if the actual call (the inbound
one,<br>
>>> from a client) gets to
opensips LB ? and if so, if the call gets<br>
>>> forwarded<br>
>>> to Asterisk ?<br>
>>><br>
>>> Regards,<br>
>>> Bogdan<br>
>>><br>
>>><br>
>>> On 03/13/2012 10:00 PM,
Joshua Nankin wrote:<br>
>>>><br>
>>>> Hello,<br>
>>>><br>
>>>> Trying to use OpenSIPS as
both a load balancer for incoming calls
and<br>
>>>> as an outbound proxy to
my carrier. I have been unsuccessful to
place<br>
>>>> outgoing or incoming
calls, and I think I just need some help
with the<br>
>>>> configuration. Just for
testing, I have one Asterisk box behind<br>
>>>> OpenSIPS and the load
balancer table on OpenSIPS looks like
this:<br>
>>>><br>
>>>><br>
>>>><br>
>>>>
+----+----------+-------------------+-----------+------------+-------------+<br>
>>>> | id | group_id | dst_uri
| resources | probe_mode |<br>
>>>> description<br>
>>>> |<br>
>>>><br>
>>>><br>
>>>>
+----+----------+-------------------+-----------+------------+-------------+<br>
>>>> | 1 | 1 | <a>sip:10.36.115.119</a>
| fax=300 | 0 | tester<br>
>>>> |<br>
>>>><br>
>>>><br>
>>>>
+----+----------+-------------------+-----------+------------+-------------+<br>
>>>><br>
>>>><br>
>>>> The dst_ur is the
internal IP of my asterisk box. I'm using
this for<br>
>>>> fax, so I have set the
resources field to 300 channels of "fax".
On<br>
>>>> my asterisk box, I've
added "outboundproxy=23.21.170.154", as
the 23.*<br>
>>>> IP is the external IP of
the opensips box. Below is my simple<br>
>>>> opensips.cfg that I've
adapted from the load balancing tutorial.
Any<br>
>>>> help would be much
appreciated. Additionally, for debugging
purposes,<br>
>>>> I've opened all UDP and
TCP ports. Still not able to connect.<br>
>>>><br>
>>>><br>
>>>> debug=6<br>
>>>> memlog=1<br>
>>>><br>
>>>> fork=yes<br>
>>>> children=2<br>
>>>> log_stderror=yes<br>
>>>> log_facility=LOG_LOCAL0<br>
>>>><br>
>>>> disable_tcp=yes<br>
>>>> disable_dns_blacklist =
yes<br>
>>>><br>
>>>> auto_aliases=no<br>
>>>><br>
>>>> check_via=no<br>
>>>> dns=off<br>
>>>> rev_dns=off<br>
>>>> port=5060<br>
>>>><br>
>>>>
mpath="/usr/lib/opensips/modules/"<br>
>>>> loadmodule "maxfwd.so"<br>
>>>> loadmodule "sl.so"<br>
>>>> loadmodule "db_mysql.so"<br>
>>>> loadmodule "tm.so"<br>
>>>> loadmodule "uri.so"<br>
>>>> loadmodule "rr.so"<br>
>>>> loadmodule "dialog.so"<br>
>>>> loadmodule "mi_fifo.so"<br>
>>>> loadmodule "signaling.so"<br>
>>>> loadmodule "textops.so"<br>
>>>> loadmodule
"load_balancer.so"<br>
>>>><br>
>>>> modparam("mi_fifo",
"fifo_name", "/tmp/opensips_fifo")<br>
>>>> modparam("mi_fifo",
"fifo_mode",0666)<br>
>>>><br>
>>>> modparam("dialog",
"db_mode", 1)<br>
>>>> modparam("dialog",
"db_url",
"mysql://root:opensips@localhost/opensips")<br>
>>>><br>
>>>>
modparam("rr","enable_double_rr",1)<br>
>>>>
modparam("rr","append_fromtag",1)<br>
>>>><br>
>>>> modparam("load_balancer",<br>
>>>>
"db_url","mysql://root:opensips@localhost/opensips")<br>
>>>><br>
>>>><br>
>>>> route{<br>
>>>> if
(!mf_process_maxfwd_header("3")) {<br>
>>>>
sl_send_reply("483","looping");<br>
>>>> exit;<br>
>>>> }<br>
>>>><br>
>>>><br>
>>>> if (!has_totag())
{<br>
>>>> # initial
request<br>
>>>>
record_route();<br>
>>>> } else {<br>
>>>> #
sequential request -> obey Route
indication<br>
>>>>
loose_route();<br>
>>>>
t_relay();<br>
>>>> exit;<br>
>>>> }<br>
>>>><br>
>>>> # handle cancel
and re-transmissions<br>
>>>> if (
is_method("CANCEL") ) {<br>
>>>> if (
t_check_trans() )<br>
>>>>
t_relay();<br>
>>>> exit;<br>
>>>> }<br>
>>>><br>
>>>><br>
>>>> # from now on we
have only the initial requests<br>
>>>> if
(!is_method("INVITE")) {<br>
>>>>
send_reply("405","Method Not Allowed");<br>
>>>> exit;<br>
>>>> }<br>
>>>><br>
>>>> # detect
resources and do balancing<br>
>>>>
load_balance("1","fax");<br>
>>>><br>
>>>> # LB function
returns negative if no suitable
destination (for<br>
>>>> requested resources) is
found,<br>
>>>> # or if all
destinations are full<br>
>>>> if
($retcode<0) {<br>
>>>>
sl_send_reply("500","Service full");<br>
>>>> exit;<br>
>>>> }<br>
>>>><br>
>>>> xlog("Selected
destination is: $du\n");<br>
>>>><br>
>>>> # send it out<br>
>>>> if (!t_relay()) {<br>
>>>>
sl_reply_error();<br>
>>>> }<br>
>>>> }<br>
>>>><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>