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).
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).
Proxy and Registration
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
PSTN-to-VOIP Gateway Setup
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’
FXO timer values (sec)
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…
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
Other than that, this is all thats needed for the PSTN Line to register to asterisk and send and receive calls.
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.
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.
In my spa-3102, my Dial Plan 2: had code (S0<:email@example.com>). 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!