Tag Archives: pstn

Configuring the OBiHai OBi110 to replace a linksys spa-3102 as a google voice and pstn gateway using asterisk 1.4

If you were looking for how to configure the SPA-3102 with Asterisk 1.4 click here.

All the rage in the VOIP world is the Obihai obi110 voice gateway device, and while due largely to its native integration of google voice, I believe it’s because it does quite a bit for a very reasonable cost (Under $50 from here!). And while just good news for asterisk 1.8 users, this is great news for asterisk 1.4 and 1.6 users! The Obi110 is essentially a user friendly linksys spa-3102 with a slightly watered down interface, with the addition of native google voice support (and setup wizards!). It is somewhat less capable in functionality (no router feature, or independent trunking capabilities with asterisk, etc.) but for my purposes, I decided to give it a try to see if I could replace my spa-3102 and found out that it could quite easily.

The obi110

I have a simple asterisk 1.4 based setup with several extensions located around the world. The main goal is for my family to connect to my system using their iphones, computers, voip devices and make calls to the US and also to receive calls with local DID numbers to their extensions. My previous setup with the linksys spa-3102 allowed them to use my ooma device to call out as an outgoing trunk, however I wanted to see if I could add two trunks to my setup and give my users the flexibility of outgoing call redundancy if they so desired (choose to call out through GV or my Ooma).

Below is my guide for setting this up.

Pre-requisites:
-Network connectivity to the obi110 and ability to administer its local web admin page and setup through obitalk.com.
-Physically connected pstn service (ooma, telco) to the obi110 local Line port (Note: if line port is disconnected, the obi110 will report the lines as busy even if just calling out through GV when the SP2 local dialplan shown below is specified).
-Newest version of firmware on the obi110 (as of 03/21/11 version 1.1.0 (Build: 1892))

Configuration:
I found that it is much simpler to initially set up the obi110 through the obitalk.com portal and then to disable auto-provisioning and make customized changes to the web admin afterwards.

Google Voice Trunk setup – obitalk.com portal
1. Goto obi110 device portal after you have successfully registered your hardware to your user account on obitalk.com
2. Configure Voice services for Service Provider 1 and select Google voice
3. Enter in your google voice email and password.
4. Make sure to put a checkmark to make this provider the default Line to call out.
5. Click submit and wait for your ob110 to reboot

Asterisk Trunk setup – obitalk.com portal
1. While still logged into the Obitalk portal, configure the Voice service for Service Provider 2 as a generic service provider (this will essentially act as an extension to asterisk)
2. Enter in your asterisk server information
3. Click submit and wait for the obi110 to reboot.

Asterisk Service provider 2 Trunk

Configure Dialplan on Obi110 device and disable Auto Provisioning
Thats all there is to setting up obi110 trunks! Couldnt be easier right? Now for the small dialplan customizations to make the incoming and outgoing calls route properly.

1. Log into your obi110 device through its web admin (enter in the devices IP address in a web browser. default user/pass is admin/admin)
2. Disable Auto-Provisioning by expanding the System Management Tree on the left pane, then clicking on the Auto Provisioning link and set the Auto Provisioning Method to Disabled. Click submit and reboot (if not disabled, your changes will get overwritten).
3. Expand the Voice Services Tree to the left and click on the SP1 Service link
4. Under X_InboundCallRoute enter in SP2 and click on submit (this routes all calls coming in from GV to your asterisk extension).

Service Provider 1 Local Dialplan

5. Under the Voice Services Tree to the left, click on the SP2 Service link
6. Under X_InboundCallRoute enter in {>(xxx xxx xxxx):sp1},{>(1xxx xxx xxxx):li1}  and click on submit

Service Provider 2 Local Dialplan

The above line in Step 6 routes any 10 digit calls out through GV (configured as SP1), and any 11 digit calls starting with 1 out through the local line port…In my case, through my ooma device). The reason you will need to do this is because unlike the spa-3102, there is no seperate interfacing for asterisk to trunk to the different Service providers which the obi110 can be configured. Instead, asterisk needs to send the dialed number in a way where the obi110 can then determine to which interface it will send its calls. In this case, I will have asterisk format the numbers to be only 10 digits if a user wants to call out through GV, and append a 1 to the 10 digit number if the user wants to call out through my ooma. Once asterisk does this and sends the number to the obi110, the obi110 will then direct the call accordingly depending on if there is a 1 in front of the number – a little hurdle, but easy enough to work around.

Double checking your Asterisk configuration settings
1. Under the Service Providers Tree to the left, click on the ITSP Profile B link
2. Make sure the settings are correct for the SIP and RTP sections. Most likely you will have to modify your RTP LocalPortMin and LocalPortMax settings to match your current asterisk RTP port range.

Thats all there is to configuring your local OBi110 device. The next steps are just to configure asterisk with the user you specified in the obitalk.com service provider 2 settings, and to create a dialplan which handles the numbers so that obi110 can route the calls appropriately.

Below is my user configuration for asterisk 1.4 so that the Obi110 can register to it. ‘gvtrunk’ is my username and ‘password’ is the password which I specified in my Service Provider 2 setup on the obitalk.com portal. Place this in your sip.conf or users.conf file.

[gvtrunk]
username = gvtrunk
fromuser = gvtrunk
secret = password
type = friend
disallow = all
allow = ulaw
allow = alaw
allow = gsm
context = gv-in
host = dynamic

Next we have to edit our extensions.conf file and to tell asterisk what to do with our calls. Below, any call the user makes whether be it 1XXX-XXX-XXXX or XXX-XXX-XXXX will be routed out to the obi110 and then through google voice. This is because I have asterisk removing the 1 digit the user has dialed so that the obi110 dialplan will route the 10 digit number to GV.

In this dialplan I also have any number with a 9 dialed before it sent out to the obi110 as a 1XXX-XXX-XXXX number. If the user has dialed a 9XXX-XXX-XXXX number without the 1, asterisk will append the 1 in front of the number to make it an 11 digit number so that the obi110 can route the call through the local line port (and out through my ooma).

_XXXX is needed because my internal extension numbers are 4 digits long. I need this so that any numbers longer than 4 digits go out appropriately and are not seen as internal extensions.

[ob110-out]
;make outgoing calls to gvtrunk with 10 digit dialing
exten => _XXXX.,1,Dial(SIP/${EXTEN}@gvtrunk,20)
exten => _XXXX.,n,Hangup()
exten => _XXXX.,n,Congestion
;make outgoing calls to gvtrunk with 11 digit dialing
exten => _1XXXX.,1,Dial(SIP/${EXTEN:1}@gvtrunk,20)
exten => _1XXXX.,n,Hangup()
exten => _1XXXX.,n,Congestion
;make outgoing calls to gvtrunk through ooma with 10 digit dialing
exten => _9XXXX.,1,Set(CHEXTEN=${EXTEN:1})
exten => _9XXXX.,n,Dial(SIP/1${CHEXTEN}@gvtrunk,20)
exten => _9XXXX.,n,Hangup()
exten => _9XXXX.,n,Congestion
;make outgoing calls to gvtrunk through ooma with 11 digit dialing
exten => _91XXXX.,1,Dial(SIP/${EXTEN:1}@gvtrunk,20)
exten => _91XXXX.,n,Hangup()
exten => _91XXXX.,n,Congestion

How to handle inbound calls from GV with Asterisk
The last thing we need to do is tell asterisk how to handle inbound calls from Google Voice. In my user setup above, I specified gv-in as the user context. This just tells asterisk where to go and how to handle the incoming calls from the obi110 device. Place this in your extensions.conf file and modify it accordingly.

[gv-in]
exten = s,1,answer
exten = s,n,wait(1)
exten = s,n,Dial(SIP/4000,20)
exten = s,n,wait(1)
exten = s,n,Voicemail(4000,u)
exten = s,n,Hangup

Above, I have all calls from GV calling my extension 4000. Just change it to your desired extension.

Thats all there is to it. It may look complicated, but the dirty work is done for you…Enjoy!

How to setup Asterisk with Ooma voip using a Linksys SPA-3102

Asterisk is one of the coolest pieces of open source software that I have come across. Its possibilities are endless, and its almost completely free (aside from all the cool gadgets you buy to expand its functionality). The reason for this blog post is to provide a better guide for setting up asterisk to communicate with an spa-3102 and interface it with ooma. In this setup, I have asterisk 1.4 running on an NSLU2 running unslung 6.10beta. Being that the nslu2 does not have much in terms of support for fxo/fxs built in or through its USB ports, the super handy dandy and small form factor of the SPA-3102 is a perfect option to get an FXO port to interface with asterisk via ethernet and be able to make and receive calls with asterisk to the PSTN (in this case to dial out and receive calls from my ooma hub).

The real motivation for me to use asterisk and ooma was to save moolah. With ooma, albeit with the up-front cost of $200, one can cancel their phone line and stop paying those pesky monthly bills. Our monthly bills were not as absorbitant as others, yet the reasoning behind me getting it was to get more for the same. I canceled my ATT $10 internet (768k down) and $10 phone with only local calling…(total monthly charge of $32-$37 with taxes and long distance charges that we didnt make), and opted for a 12mb down 512k up cable internet connection for $37.99. I would then still have a home phone number which I could take with me if I moved, and have super fast internet (in my standards). With asterisk in the mix, I could then share out my ooma with my family and allow them to make calls to the US for free as well (my sister lives in australia). Also, if I am overseas, I can make free calls to the US. I also have gizmo5 and google voice working together to provide my individual extensions in asterisk with DID numbers, but thats for another post.

For those of you who do not know what ooma is, its a VOIP hardware solution which gives you a dedicated phone line and “unlimited” calling to the US, all you need is an internet connection. I got my ooma core from radio shack for $199 and will never have to pay phone bills again (ooma core does not have an annual regulatory fee, while the ooma telo, and ooma hub only, does). Ooma makes its money off the upfront cost of hardware, and also by selling its ooma premier service. This service gives you cool features, but features that asterisk allows you to do and with more customization (and maybe for a little more effort). The Linksys SPA-3102 is an ethernet voice gateway with FXO port that has the added functionality of routing, and it also acts as an ATA to allow your regular analog phone to connect with a VOIP provider using the FXS port (If you don’t have an SPA-3102 yet, you can get one from here).

Ooma hub wiring setup

The Ooma hub can be hooked up to your existing phone lines in several ways. Currently, I have my ooma phone port plugged directly into my existing home wiring jack with a splitter which also has my fax/answering machine plugged into it. This configuration allows all the phone jacks in my home to access the ooma hub without the use of the ooma scout. This is essentially the same wiring configuration as one receiving phone service from the telco. However, you lose the instant second line feature you would otherwise be provided when using the ooma scout adapter. To connect the SPA-3102, just plug a phone cord from the Line port on the adapter to a jack in the wall, or if it is near the ooma hub, into a splitter which shares a line plugged into the Phone port on the Ooma hub (or directly into the hubs phone port without a splitter). If you are on a call using a phone plugged into my wiring configuration and dial out using asterisk through the Line port on the SPA, the adapter will report a 503 message to asterisk and stop the call from taking place and interrupting.

If one wants to make sure the line is not busy when receiving/making a call when using the ooma as a regular analog telephone line as well, another configuration one can use, is to hook up the ooma scout and connect it directly to the ooma hubs ‘wall’ port via phone line. One would then connect a phone line from the SPA-3102 Line port to the scouts ‘wall’ port. This enables the scout to communicate with the ooma hub and enables the instant second line feature should the first line be active when a call out from the asterisk box takes place.

Linksys SPA-3102 Configuration

SPA-3102 Remote Management for LAN Setup

The SPA-3102 has four interface ports in the rear, Internet, Ethernet, Phone, and Line. If you plug in a computer to the ethernet port via cable, it will provide your computer with an ip address with which you can then enter in the gateway address from an ipconfig and hit the spa3102 web gui. With this web gui, youll be able to configure the device. We dont want to have to plug in a cable each time to configure the device, so we will enable the web interface on the spa3102 when it is connected to the Internet port (with which it will receive a dhcp address handed out to it from your router currently on your network).

-Log into the webgui for the spa-3102 when you are connected to the ethernet port
-Click on the admin and advanced links at the top right to get the elevated setup access
-Goto ‘WAN Setup’ Tab
-Change ‘remote management’ option to ‘yes’
-Click the ‘submit all changes’ button at the bottom.

-Connect your spa-3102 to your network via the internet port.
-Log into your spa-3102 and look at the status screen with the computer still plugged into the ethernet port on spa3102. You will find the dhcp address the spa-3102 received from your router which is connected to the Internet port.
-Disconnect your computer from the ethernet port on the spa-3102
-Log into your 3102 via the dhcp address that it received from the internet port.

SPA-3102 PSTN Line Setup:

Now we begin the configuration of the SPA to be used with asterisk. In this setup, I will not enable Line1 which makes the SPA-3102 an ATA adapter as well (allowing calls made to your voip provider to ring the analog phone connected to the PHONE port). In this setup, I just use the SPA as a gateway which allows me to make and receive calls (using the LINE port on the SPA) from any extension that is connected to my asterisk pbx. Under the LINE 1 tab in the SPA, ive set “Line enable” to no.

NOTE: When things are configured properly, and the PSTN Line is registering with asterisk, the LINE LED on the SPA will light up and remain lit (same with the Phone port if Line 1 is enabled). If things arent communicating correctly, the LED will not be lit (I have the spa registering to asterisk).

-Log into the SPA web gui
-Click on the admin and advanced links at the top right to get the elevated setup access
-Click the ‘PSTN Line’ tab

Proxy information

Where you enter in your asterisk server IP info and whether or not it will register to asterisk.

Proxy and Registration

Proxy – Change 192.168.1.77 to the ip address asterisk is on your network. I put the ip in the outbound proxy, its not necessary as ‘Use Outbound Proxy’ is set to ‘no.’
Register – ‘yes’
Make call without reg and Ans call without reg – Change options to ‘no’

Subscriber Information

Display name – can be anything
User Id – can be anything but for simplicity sakes when configuring asterisk, use a name without spaces
Password - can be anything

Dialplan stuff

This is where you enter dialplan information, and options to configure sending calls from asterisk to the pstn port.

Dial Plans

This section of dial plans are accessed by the entire page of the SPA PSTN Line tab. There are eight DP fields because it allows you to create different dial plan options to be used throughout this tab. Voip-to-PSTN, and PSTN-to-VOIP sections both reference these dialplan fields as ‘DP.’ As you can see in my screenshot, Dial Plan 2: is filled out. In my setup, this command tells the SPA that any calls answered after the PSTN-to-VOIP gateway option answer delay is reached, to be sent to the S extension in asterisk. You may enter any extension such as (S0<:102@asteriskIP>).

VOIP-to-PSTN Gateway Setup

VOIP-to-PSTN gateway enable – ‘yes’
Line caller DP – set to ‘1’ (this option references Dial Plan 1:  and the default (xx.). This just passes anything sent from asterisk to the SPA without any change)
One Stage Dialing – set to ‘yes.’ If set to no, then the SPA uses 2 stage dialing, and it screws up asterisks calling out to the Line port.

voip spa-3102

The PSTN-to-VOIP configuration, where you configure how to send calls from the Line port (pstn) to asterisk

PSTN-to-VOIP Gateway Setup

PSTN-to-VOIP Gateway enable - ‘yes’ (in the screenshot above, i have it set to ‘no’ as I do not want the spa to pick up the line and forward to my extension s@192.168.1.77 as defined in Dial Plan 2:. This essentially turns off any calls going to my asterisk system. I have my asterisk system setup to forward the call from the pstn to my cell phone when this is turned on, and only used while traveling far away from home. When I am not traveling I have a fax/answering machine on my ooma and want it to pick up instead, so it is disabled.

If you are in an asterisk/voip only configuration and want all calls to be routed straight to your asterisk system without worrying about any analog answering machines or fax picking up/ringing, then set to ‘yes’

PSTN CID For VoIP CID – set to ‘yes’ if you want callerid to be passed onto your asterisk system
PSTN Caller Default DP – set to ‘2’ as in my Dial Plan 2: it allows calls to be routed from Line port (pstn), to extension S on my asterisk pbx

FXO timer values (sec)

PSTN answer delay – this option is to change the length of time the SPA-3102 picks up the call coming in from the PSTN and forwards it to your asterisk system. The default is 16 which allows the line to ring for a little too long before sending it off to Asterisk. A number of 3-5 should be good for callerid to be gathered and sent along with the call to asterisk.
PSTN Dial Digit Len – set to .1/.1 otherwise calls may take longer to start connecting. This essentially shortens the speed at which digits are dialed at. You dont want digits to take forever to be entered do you?

Awesome. You are now finished configuring your SPA-3102 to act as a SIP trunk on the SPA-3102 side. All you need from here to configure asterisk is the username and password you specified in the Proxy and Registration section. Now on to the Asterisk side of things…

Asterisk Configuration

This setup is for asterisk 1.4. I found that many guides found on the internet do not seem to work for my setup. I was not able to set my SPA as a peer, but had to configure my 3102 to register to asterisk as an extension in order for everything to work correctly. I also found many internet guides had sip trunk settings which were no longer used for version 1.4. Now lets tell asterisk theres a device to communicate with in the Users.conf (for you it might be Sip.conf) file in the asterisk directory.

Users.conf or Sip.conf

Users.conf or sip.conf configuration in asterisk. this command sets up the SPA to be used as an extension from which calls can be made and received.

[pstn] – Put the username you specified on the SPA-3102 in between brackets. In my example above, replace [pstn] with your username. The tricky part here is that the name between brackets is your username, even if you specify username = as something else, asterisk will not allow your 3102 to register with it.
type = friend – Sets as an extension which can be dialed out from (see here for more info)
port – I saw several guides saying to put in port = 5061, this is unecessary as this configuration automatically connects to this port. You may need this if it was set to type=peer, but I was never able to get it to work as one.
disallow – This configuration also disallows any voice codec other than ulaw, alaw, and gsm as the NSLU2 does not have enough horsepower to transcode the higher compression the other codecs use.
context = pstn-in – this is the label for where incoming calls are sent to in my extensions.conf file.
host = dynamic – as the spa is registering to asterisk, the ip address of the 3102 does not need to be specified here and will be obtained during the spa-3102 device registration. I could change the ip address of the spa-3102 on the unit and it would still register with asterisk.
secret = passwd – replace ‘passwd’ with the password you entered in the spa-3102

Other than that, this is all thats needed for the PSTN Line to register to asterisk and send and receive calls.

Extensions.conf

Extensions.conf is the the file which tells asterisk how to handle incoming/outgoing phone calls.
Lets configure outgoing calls first, as it requires very little configuration. Below is all i need to put into my default context in order to make outgoing calls out of the Line port (we previously specified ‘pstn’ as a trunk/user in users.conf/sip.conf) on my SPA-3102. Below, the _XXXX. tells asterisk that any number dialed with more than 4 digits should go out through the SPA (I have 4 digit extension numbers configured). Without this configuration, asterisk would try to place a call to an internal extension number, only to find that the extension (the phone number dialed) did not exist.

Outgoing to pstn

Simple outgoing dialplan used in the default context in my extensions.conf

In my users.conf (maybe your sip.conf) file, I had the pstn user (pstn is the username specified in the spa3102) use context pstn-in as the label to goto which contains the code for how to handle the calls coming in from the Line port or PSTN.

extensions.conf

Extensions.conf tells asterisk how to handle a call. pstn-in is the context defined in my users.conf/sip.conf

In my spa-3102, my Dial Plan 2: had code (S0<:s@192.168.1.77>). This essentially sent the incoming call from the PSTN Line to the S extension in asterisk. Asterisk knows that the call is coming from the pstn user defined in the users.conf/sip.conf file, and found that context pstn-in was specified. It then initiated the commands under the pstn-in section. The commands listed above, answers the call, plays a sound file that nobody is available to take the call, then says “call-forwarding” and proceeds to ring my cell phone number (8001112222 is the cell number, change it as desired. proxy01.sipphone.com is my gizmo account which forwards it out through a google voice DID number).

Alternatively, if you just want to have the incoming pstn call sent to several or all extensions on your asterisk system, you can substitute my ‘Dial’ line with the one below and change my extension numbers to match yours (where 6000, 6100, 6200 are my extensions/phones registered with asterisk):

exten = s,n,Dial(SIP/6000&SIP/6100&SIP/6200,20)

Thats all there is to it, good luck!