News:

On Tuesday September 6th the forum will be down for maintenance from 9:30 PM to 11:59 PM PDT

Main Menu

Multiple GV outgoing on Obi thru FreePBX/Asterisk

Started by hapollo, July 17, 2016, 04:35:53 PM

Previous topic - Next topic

hapollo

Ok. so I decided to set up an Asterisk with FreePBX GUI running on a Raspberry pi (RasPBX) to avoid the OBiPortal. Due to the latest recent permanent downtime since SSL was deprecated for TLS after July 6, I set this up to allow future expansion and other reasons.

It was not as smooth as I had first thought b/c of so many layers in my setup- between callcentric incoming for caller ID, multiple google voice outgoing on asterisk and call routing on Obi110/200s, I spent a good part of the weekend troubleshoot various issues.

The part that I stumped on after searching all over the fourms is how to route GV Outgoing calls on OBi SP2 vs SP4 through Asterisk. In the past, dialing 10 digits went out SP2, **4 went out SP4. Now, **4 doesn't work and the call only goes out the 1st Outbound Route in the FreePBX setup. If I move the 1st outbound route down one, the other that moves up becomes the default outgoing. How do I tie a specific SPx to a specific outbound route and not the first in the Outbound Route order? Is it based on dialing patterns?

I'm pretty sure, I'm missing something on the outbound routes GUI to distinguish SP2 from SP4 to route the call through the respective GV.

OBi Call History shows **4 goes out on SP4 but Asterisk sends it out on whatever is on the 1st Outbound Route.  Even tried to Prefix Dial Patterns on Outbound Routes to **4. Seems the **4 gets stripped somewhere between Obi and Asterisk.

Soultion? Any Asterisk/FreePBX gurus!

restamp

I must confess I don't understand your "sp2 vs sp4" thing.  What worked for me is to set up routes to Service Provider profiles (trunks) on the OBi that connect to Asterisk as internal extensions.  Then to Asterisk, when you send a 10-digit number to SP2, it's the equivalent to Asterisk of someone picking up a local phone and dialing that number.  You also get the benefit of any other Asterisk features on these lines.  On my Asterisk, I used pjsip to configure the local extensions.

By default, all external calls originated on the server (i.e., on its local extensions) will go to the first Asterisk outbound trunk which was set up.  If you want to route different extensions to different Asterisk outbound trunks, you'll have to play with the "Dial Patterns that will use this Route" options under Connectivity > Outbound Routes.  (Normally, you would simply configure the CallerID that a given outbound channel will reflect for that call so that the actual hardware over which the call is placed wouldn't matter, but since GV lines do not allow their CallerID to be altered, I suppose juggling the trunks themselves becomes a practical necessity.)

hapollo

Thanks for the replied suggestion . I resolved it by inserting a dial prefix
in the dial patterns for each Outbound Route with a modification in the OBi Phone port OutboundCallRoute from {(<**2:>(Msp2)):sp2} to (<**2:"Prefix">(Msp2)):sp2}. This way I kept the existing **X outbound routes on the obi and let Obi replace the **X with the appropriate Prefix # for the correction google line.

Should I add a few more Google voice accounts to Asterisk, I'll need to rethink this to accommodate more extensions. But for now, all I wanted to do was solve my SSL to TLS authentication issue after Google finally shut it down this month after a few outages ad keep the existing calling scheme we've used for nearly 5 years with GV.

restamp

Glad you got your problem resolved to your satisfaction hapollo.  (Your solution is essentially the same one that I would have chosen).

This thread, though, touches on a question that has been floating around in the back of my mind for some time concerning Google Voice:  Does Google take an interest in or care how many XMPP sessions terminate on a given IP address and if so, at what point do they consider that number excessive?  I've been reluctant to assign too many GV lines to my Asterisk server or OBis for that reason, although I could certainly use a few more.  (Unlike hapollo, my Asterisk server resides on an external VPS with its own IPv4 address.)

Anyone know?

SteveInWA

Quote from: restamp on July 24, 2016, 10:48:18 AM
Glad you got your problem resolved to your satisfaction hapollo.  (Your solution is essentially the same one that I would have chosen).

This thread, though, touches on a question that has been floating around in the back of my mind for some time concerning Google Voice:  Does Google take an interest in or care how many XMPP sessions terminate on a given IP address and if so, at what point do they consider that number excessive?  I've been reluctant to assign too many GV lines to my Asterisk server or OBis for that reason, although I could certainly use a few more.  (Unlike hapollo, my Asterisk server resides on an external VPS with its own IPv4 address.)

Anyone know?


You can have several different Google accounts signed in at the same location.  Keep in mind that Google Voice is intended for individual/personal use, and it's not intended to be a source of free PBX trunks.  Creating multiple accounts for commercial purposes is a violation of the Acceptable Use Policy, and if certain usage patterns are detected, Google will shut down the account(s).

azrobert

#5
I used a different approach. What you did works fine, so I'm not suggesting you change anything. I'm just showing you a different method.

I'm assuming you have sp2 and sp4 registered to Raspbx as different extensions. You route 10 digit numbers to sp2 and **4 prefixed numbers to sp4. Is this correct?

1st, to route the **4 prefix to Raspbx make the following change in your OBi:
{(**4(Msp4)):sp4}

Now the **4 prefix will not be removed, so you don't have to add a 2nd prefix.

I routed calls in Raspbx by extension number, not by prefix.
I removed the **4 prefix before sending the call to Raspbx and just put the extension number into the callerid parm of the raspbx outbound route.

Edit:
You don't need to use a SPx trunk to point to a Raspbx extension. You can use a Voice Gateway.

hapollo

#6
Quote from: azrobert on July 24, 2016, 12:19:35 PM
I used a different approach. What you did works fine, so I'm not suggesting you change anything. I'm just showing you a different method.

I'm assuming you have sp2 and sp4 registered to Raspbx as different extensions. You route 10 digit numbers to sp2 and **4 prefixed numbers to sp4. Is this correct?

Actually 10 digits are routed to an offsite OBi110 which I didn't want older family members to have to remember **2 codes and such. The Sp2 and Sp4 are on a local Obi200 which forward to 2 cell phones, respectively.

Quote from: azrobert on July 24, 2016, 12:19:35 PM
1st, to route the **4 prefix to Raspbx make the following change in your OBi:
{(**4(Msp4)):sp4}

Now the **4 prefix will not be removed, so you don't have to add a 2nd prefix.

I actually did a **2 /**4 Prefix in RasPBX as noted in my very first post above, mentioned it was being stripped. Now I realize it was the simple colon removal that made the difference!!

Quote from: azrobert on July 24, 2016, 12:19:35 PM
I routed calls in Raspbx by extension number, not by prefix.
I removed the **4 prefix before sending the call to Raspbx and just put the extension number into the callerid parm of the raspbx outbound route.

I also tried that in my experimentation using the extension number in the caller ID parm of the RasPBX outbound route and also the the actual 9 digit callerID number. Can you clarify if it makes any difference to use an extension or the actual CallerID number in that field? Wasn't quite sure what it was looking to match when it's placed in that Outbound Routes CallerID field when a prefix will already match.

Quote from: azrobert on July 24, 2016, 12:19:35 PM
Edit:
You don't need to use a SPx trunk to point to a Raspbx extension. You can use a Voice Gateway.

I actually tried that as well when experimenting but got the 403 error because I put the IP address of the RasPBX after sp2 in the accessnumber field of the Obi Gateway sp2(192.168.XX.XX). I just removed it and now the gateway works without any authentication info. Why does this not need anything besides a proper DigitMap? While it seems this will allow multiple outgoing calls. Only incoming calls registered to a proper spX will ring, right?

Thanks for this, azrobert. It helped clarify alot of things and made me understand where some of my previous experimentation went wrong.

azrobert

#7
QuoteNow I realize it was the simple colon removal that made the difference!!
You also have to remove the "<>"
_______________________________

I'm totally confused on how you're routing calls to Raspbx, so I'll just explain my setup.

I have an OBi200 with SP3 registered to Raspbx as extension 1000

I have an OBi110 without an open SP trunk, so I have a VG pointing to Raspbx as extension 2000.
I changed the port number in Raspbx, so the VG definition looks like this:
AccessNumber: sp2(xx.xx.xx.xx:pppp)
AuthUserID: 2000
AuthPassword: password

I use a zero prefix to route calls to Raspbx in both devices.
I strip off the zero before routing the call.

Raspbx outbound routes looks like this:

Trunk1
Pattern: NXXNXXXXXX
CallerID: 1000

Trunk2
Pattern: NXXNXXXXXX
CallerID: 2000

You can use a prefix OR extension number to route calls.
It's redundant to use both.
______________________________

The 403 error means Forbidden.
My Raspbx doesn't require my extension to be registered.
Maybe your version does.

My OBi110 isn't registered to Raspbx.
I do have a trunk defined on Raspbx pointing to the OBi110.
I need this trunk, so Raspbx knows the IP address of the OBi110.
If I route inbound OBi110 calls to Raspbx without this trunk defined, the call will be treated as anonymous and be rejected with I think a 403 error.
You are supplying credentials, so it shouldn't be considered anonymous, but maybe it will.
You can try defining a trunk pointing to your OBi on Raspbx and see if it clears the 403 error.

Define it like this:
Trunk Name: OBixxx
Outbound CallerID: any number
Peer details:
type=peer
username=anything
host=xx.xx.xx.xx     (OBi IP address)
port=5061
canreinvite=no
insecure=invite,port
qualify=yes

No Register String
__________________________

It's a mystery to me why removing the VG access number works.
___________________________

QuoteWhile it seems this will allow multiple outgoing calls. Only incoming calls registered to a proper spX will ring, right?

You can change the extension definition to route inbound calls to the IP address of the OBi.
The default Dial command looks like: SIP/2000
Change it to: SIP/0@xx.xx.xx.xx:5061

That's the IP address and port of SP2 on the OBi.
The OBi SP2 inbound call route must be able to accept this call.

Edit:
If you use a prefix to route outbound calls, you only need to define 1 extension.
Route all prefixes to the same extension then have 2 outbound routes.
I don't know if you need to route inbound calls to different destinations.


hapollo

#8
Thanks azrobert, I'm with you for the most part as well but in reading these post, I realized I needed to step back and not take these examples literally but to use as a guideline depending on how my Obis have been set up.
With that I am wondering:
Quote from: azrobert on July 24, 2016, 08:44:22 PM
I changed the port number in Raspbx, so the VG definition looks like this:
AccessNumber: sp2(xx.xx.xx.xx:pppp)

Did you change the port number to accommodate the VG or to avoid SIP scanners? I get confused as to when ports need to be changed for reasons other than SIP scanners as I notice SP1,2,3,4 on Obi200 use 5060,61,62,63 on xUserAgentPort but most places I've read say multiple SIPs can all use 5060 at the same time.

Quote from: azrobert on July 24, 2016, 08:44:22 PM
You can try defining a trunk pointing to your OBi on Raspbx and see if it clears the 403 error.

Define it like this:
Trunk Name: OBixxx
Outbound CallerID: any number
Peer details:
type=peer
username=anything
host=xx.xx.xx.xx     (OBi IP address)
port=5061
canreinvite=no
insecure=invite,port
qualify=yes

No Register String
__________________________


QuoteWhile it seems this will allow multiple outgoing calls. Only incoming calls registered to a proper spX will ring, right?

You can change the extension definition to route inbound calls to the IP address of the OBi.
The default Dial command looks like: SIP/2000
Change it to: SIP/0@xx.xx.xx.xx:5061

That's the IP address and port of SP2 on the OBi.
The OBi SP2 inbound call route must be able to accept this call.

Thanks, after following this as a template and not literally using port 5061 since my SP4 allows incoming calls but not SP2, I changed the above to port 5063 for SP4 and can register multiple GVs # to allow incoming calls to Obi.


Quote from: azrobert on July 24, 2016, 08:44:22 PM
Edit:
If you use a prefix to route outbound calls, you only need to define 1 extension.
Route all prefixes to the same extension then have 2 outbound routes.
I don't know if you need to route inbound calls to different destinations.


Not quite sure I follow this, although when I did register my vg2 as suggested:

I changed the port number in Raspbx, so the VG definition looks like this:
AccessNumber: sp2(xx.xx.xx.xx:pppp)
AuthUserID: 2000
AuthPassword: password

Now I get a busy signal when I dial out vg2 while Asterisk CDR show it going out with the correct prefix and Busy while Obi200 Call history shows

SP4("NumberIcalled"@192.168.XX.XX:5060) Call Ended (486 Busy Here)

Is that why you changed the port number above or something else causing this Busy error?

After I get Outbound Calling over VG working properly, I think I'll have the proper framework for future expansion and flexibility using Asterisk/FreePBX and various Obi configs.

Thanks in advance azrobert!


NoelB

#9
Quote from: hapollo on July 25, 2016, 03:48:48 PM

Did you change the port number to accommodate the VG or to avoid SIP scanners? I get confused as to when ports need to be changed for reasons other than SIP scanners as I notice SP1,2,3,4 on Obi200 use 5060,61,62,63 on xUserAgentPort but most places I've read say multiple SIPs can all use 5060 at the same time.

Just chiming in briefly. I have a very similar setup to azrobert with VG on an obi110 setup to point to my asterisk. I started off ignoring ports with the intention of changing them for better security later but just havent got around to it. So my VG access number is just sp2(192.168.1.34) with AuthUserID as obi110.
In asterisk I use type=friend for extensions with host=dynamic and defaultuser=obi110.
When an Invite comes from VG it comes to asterisk 5060 by default and asterisk knows from the received pkt it comes from obi110 at 192.168.1.103:5061 ( my obi addr) so now it knows everything it needs to match on obi110 and setup the call correctly.
I am not suggesting that my asterisk settings are better just that asterisk can be setup in many different ways and still work correctly. I have a no frills version so have to enter all settings via CLI.

azrobert

My Raspbx port change was only for security reasons. The VG will work with port 5060. I don't know why I posted that I made the change. It only confused things. If you want to make the same change the port number is found here:
Settings -> Asterisk SIP Settings -> Chan SIP -> Bind Port 

If you change the Raspbx Bind Port, you will also have to change ports on any SP trunk registered to Raspbx.

Service Provider -> ITSP Profile X SIP
ProxyServerPort
OutboundProxyPort
_________________________

I don't know why you're getting a Busy. Are you stripping off the prefix in the Raspbx outbound route?

_________________________

I said
QuoteIf you use a prefix to route outbound calls, you only need to define 1 extension.
Route all prefixes to the same extension then have 2 outbound routes.

For Example:
You have 2 trunks defined on Raspbx
You want prefix **1 to be routed to Trunk#1
You want prefix **2 to be routed to Trunk#2
Define 1 extension on Raspbx
Register SP1 to the extension
In the OBi route both **1 and **2 to SP1
Define 2 outbound routes on Raspbx
Route#1 **1 routed to Trunk#1
Route#2 **2 routed to Trunk#2

This will work for outbound calls, but if you want to route inbound calls differently from each trunk you will need 2 extensions.

I wasn't sure about simultaneous calls on a single extension, so I tried and it worked. I made a call using my extension 1000. While the call was in session, I made a call from another device using the same extension and it worked.

hapollo

#11
Thanks azrobert. All good now. For other readers what worked for me is the following:

1) One Extension for multiple GVs using Prefix match in Dial Pattern to differentiate each GV.
2) SPx with Authuser & password set to the extension above, gives Multiple GV connections
3) Dial field setting in Extension set from SIP/"Ext#" to SIP/0@"ObiIP":"SPx-X_UserAgentPort"
4) All Inbound routes Destination field set to the One Extension# above with ANY CID

As Security precaution, I installed Fail2ban to block multiple brute force attacks, added the Oleg method while changing my 5060 port to minimize Sip Scanners and added Firewall scripts to my router to drop certain packets.

Everything looks good.

Still having issues with prefix matching on outgoing calls when changing <**x:ext#> to ext# . I just want to minimize Phone1 Port outgoing call routes character count and allow more flexibility since ** codes are limited, but will experiment further but I'll live with **x for now. Sure there are other things I can tweak as well, I just need to research a little more to enhance my knowledge.

Thanks azrobert, restamp and NoelB for your input and replies.


EDIT: Seems the <**x:ext#> to ext# (603 Declined) error is traced to my digitmaps in OBi for ISTP X for SPx.
Changing (1xxxxxxxxxx|<1>[2-9]xx[2-9]xxxxxx|1[2-9]xx[2-9]xxxxxx) to (xx.) fixes it but there is a long lag in call out.

azrobert

Quote from: hapollo on July 26, 2016, 08:42:38 AM
EDIT: Seems the <**x:ext#> to ext# (603 Declined) error is traced to my digitmaps in OBi for ISTP X for SPx.
Changing (1xxxxxxxxxx|<1>[2-9]xx[2-9]xxxxxx|1[2-9]xx[2-9]xxxxxx) to (xx.) fixes it but there is a long lag in call out.

When the dialed number matches a rule ending with "x.", you will get a 10 second delay.
You can override the delay with this: (xx.S3)

The better way is to have a DigitMap that exactly matches the number.
If you have a 2 digit prefix (10, 20 and 30) followed by a 10 digit number, use this:
([123]0xxxxxxxxxx)
or
((10|20|30)xxxxxxxxxx)

hapollo

#13
Quote from: azrobert on July 26, 2016, 02:44:44 PM
Quote from: hapollo on July 26, 2016, 08:42:38 AM
EDIT: Seems the <**x:ext#> to ext# (603 Declined) error is traced to my digitmaps in OBi for ISTP X for SPx.
Changing (1xxxxxxxxxx|<1>[2-9]xx[2-9]xxxxxx|1[2-9]xx[2-9]xxxxxx) to (xx.) fixes it but there is a long lag in call out.

When the dialed number matches a rule ending with "x.", you will get a 10 second delay.
You can override the delay with this: (xx.S3)

The better way is to have a DigitMap that exactly matches the number.
If you have a 2 digit prefix (10, 20 and 30) followed by a 10 digit number, use this:
([123]0xxxxxxxxxx)
or
((10|20|30)xxxxxxxxxx)



Thanks, I just resolved this 5 mins ago and logged on to post my resolution to find your suggestion posted as well.

Changed my standard N.A. call Digitmaps from (1xxxxxxxxxx|<1>[2-9]xx[2-9]xxxxxx|1[2-9]xx[2-9]xxxxxx) to (xx1xxxxxxxxxx|xx<1>[2-9]xx[2-9]xxxxxx|xx1[2-9]xx[2-9]xxxxxx) and then prefixed all extensions on the outbound dial pattern with 2 digit prefixes to dial out.


It's all starting to make sense now but still so much to learn! Thanks again for your wizardry!

hapollo

#14
So it seems another issue cropped up since setting up this asterisk:

We sometimes call between remote (offsite) Obi110 and local (same subnet) Obi200 using the Obitalk (9digit device#) network.

When a call comes in via Obitalk or an associated Obion App, it is set up to fork the call to a cell phone# by calling out Sp2 in case the other is out and about.

After the setup of the asterisk, calls in the direction of the local Obi200 to the remote Obi110 fork properly. However, when calls come from the remote Obi110 or Obion App into the local Obi200, calls don't fork. When setup to fork out SP2 like previously, the Obi reboots after the first ring. If setup to fork out the VG, the device does not reboot but call history shows it gets a 503 error. Normal calls going out the VG are fine when the Obitalk forking call is not involved.

Is this some sort of port conflict when going out Sp2 vs VG?

azrobert

Are you forking the call to SP2 on the OBi110?
What (service provider?) is defined on the OBi110 SP2?
If you don't fork the call and just send the call to the OBi200, does it work?

Do you have separate OBiHai accounts for each OBi or just a single account for both?
For the OBiON that's failing, which OBi is the Gateway OBi?
Are you calling the OBi200 from OBiON?
How are you calling from OBiON?

hapollo

#16
Ok, after some further testing, I realized what was causing the issues and so many headaches for me!

Most of my testing after the installation of the Asterisk was using an Obion App on an Android Phone here to call into the remote Obi110 via Obitalk and call back out. The logic being that since the remote Obi110 is too far away, I'd call into it and call out as if I was actually there rather than have my parents test it.

So, as an experiment, I turned off the Wifi on my Android and used Cellular Data to call out using the Obion App, the 503 error went away and forked calls did go out SP2 and VG on the Obi200 but ended as soon connected.

All I wanted to do was use the Asterisk to replace the GV authentication and Obi firmware updates needed.
Is it safe to assume, if I didn't change anything aside from the GV authentication originally asked above, everything else should function as it did prior to Asterisk?

I guess the underlying question is how do I properly test calls going out of the remote Obi110 will work when I can't physically be there? Obviously, calling out on a Obion App to the Obi110 to call back out causes errors which I can assume are what would be considered calling loops? Otherwise, will have to use the Obis in the most basic way until I can be there during year end holiday gatherings.

hapollo

#17
Well Obitalk forking finally resolved!

Turns out VG2 was wrongly defined as SPx(AsteriskIP:Port#) matching SPx xUserAgentPort when it should've simply been 5060.

In the end, I guess, if someone could post some simply rules of when to use 5060, when to change to match SPx and when/if you do change ports where the corresponding changes should be made in Obi, or Asterisk vice versa could be helpful and solve 80% of issues people have with errors or audio issues.

But I learned alot in a short time. Thanks all.

NoelB

#18
Quote from: hapollo on July 28, 2016, 04:32:34 PM

In the end, I guess, if someone could post some simply rules of when to use 5060, when to change

If you ignore changes you may like to make for added security you probably never need to change default ports. Every sip pkt contains a source port (src) and a destination port (dst). Each sip server such as asterisk listens on a specific port normally 5060 so all pkts sent to a sip server must contain a destination port that the server is listening on. The pkts can be sent from any src port you like . Mostly this will default to 5060 but this src port is often changed either by your router (if the server is not on your lan ) on the public side to address conflict with another client sending pkts to the same IP:5060 or by a setting change you may make to thwart port scanners. If you are going to change make it a significant change outside the likely scan range of scanners eg 4xxxx rather than say 5070. Each of your sip clients can use the same port on the same lan. The obi however defaults to a different port for each spx but other atas  with multiply itsps are forced to all use the same port. This is handled by the nat in your router and you dont even know about it unless you can see the nat sessions set up as each pkt enters the internet.
Asterisk is  just another sip  server but without a nat between client and server but also a server that is able to be configured. Asterisk by default will listen on 5060 and all the sip clients such as obi will send to 5060 by default . If however you change the asterisk listening port then you must make the same change to the DST port the obi sends msgs too. When a pkt is sent to any sip servers including asterisk the server keeps a record of received= and rport= which are the source IP:port of all pkts sent to it so they just respond to the same IP:port that the pkt came from and the nat at your end ( if relevant) will send it on to the correct client.With the obi on default asterisk will read the src port as 5060/1/2/3 and will know where the response must be sent even though there will only be one IP address.

hapollo

#19
Okay after digesting all the info above and using OBi with FreePBX on GV for nearly a week. Tweaking things I managed to get multiple SIP providers onto Asterisk similar to the SPx's on Obi. This includes Localphone and Onesuite which were set up on Obi for lowest cost call routing via Gateways and Digitmaps. Now they are on Asterisk/FreePBX simple as Trunks with only Outbound Routes.

The only left for me to do is try to make it as similar as possible without having to dial  prefixes. In other words, it the past, I had set up call routing to certain countries based on int dial codes using custom digitmaps to route out one SIP provider via SPx or Gateway on another.

It tried what I think is the same method using Match Pattern with Asterisk extension as the CallerID parm and no prefixes, but calls don't go out that Trunk as expected.

Any suggestions on what to look for to make this transition as seamless as possible?