Posts Tagged ‘Linksys SPA 3102’

Configuring Linksys SPA 3102 for Asterisk

Thursday, January 1st, 2009

As I mentioned in my previous post, I've been working on installing Asterisk.  I purchased a Linksys SPA 3102 ATA device.  It has FXO and FXS ports as well as two ethernet ports to go between your Internet connection and router.  The FXO port accepts a dial tone from the phone company and the FXS port generates one for your phones.  Since I have DSL and the phone line that comes along with it, I wanted to make use of that for local and emergency calls.

Because this device has so many configuration options, I wanted to document what I did in case I need to refer back to it in the future.  At some point, I'd like to look into creating an XML file to provision the device.  But I'm not ready for that yet.  Most of what I did was based on this forum post, but I didn't follow it exactly.

I've installed Asterisk on my Linode, which is on a static ip out on the Internet, and I've installed the SPA-3102 behind my home router, which is a WRT54G running the Tomato firmware behind a dynamic ip.  Since I have DSL, I have a combination DSL modem and router in one.  It's pretty limited in what it can do and I was afraid of it interfering with the VOIP traffic.  What other people recommended (online somewhere) was to put the DSL modem into bridge mode and configure my WRT54G to establish the PPPoE connection.  A useful tip from one of the forums was to clone the MAC address of the DSL modem to the WRT54G WAN port, otherwise you might end up in a situation where you need to call tech support.

With the home network reconfigured, it was time to get started with the SPA-3102.  My first order of business was to flash the device with updated firmware and reset it to factory defaults.  When I downloaded the flash, I was let down to see that you needed to run some flash program under Windows.  I later found out you can put the firmware image on a web server and use an "Upgrade URL" to flash the device (get the Admin Guide and search for "upgrade url" for more information).  For me, the flash and reset procedure went something like this..

  1. Turn off wireless on your laptop.
  2. Connect your laptop to LAN port of SPA-3102.
  3. Connect the WAN port of the SPA-3102 to your local network.
  4. Browse to from your laptop (make sure you click admin and advanced to see all of the configuration options).
  5. Note the WAN IP address the SPA-3102 was given.
  6. Enable the WAN web server (under Router->Wan Setup).
  7. Went to my desktop computer and fired up the Windows virtual machine.
  8. Under Windows, I opened the remote web management to verify I could connect to the WAN IP of the SPA-3102.
  9. Ran the firmware updater and followed the prompts.
  10. After the firmware update is complete, verify the version by browsing to the web management interface.
  11. Connect a phone to the phone port of the SPA-3102 (you should hear a dial tone).
  12. Dial **** to access the IVR.
  13. Dial 73738# to perform full factory reset.
  14. Dial 1 to confirm the action.

Now that the upgrade and reset procedure is complete, I returned to the laptop to enable the WAN web server again.  I then put my laptop away and finished configuring the device from my desktop computer.

As you should have noticed by now, the web management of the device is broken down by router options and voice options.  I configured the router options first.  This is a little misleading as I'm not using the device as a router, but that is where some of the basic networking options are kept.  Before configuring the basic stuff, I went to my WRT54G and gave the device a static DHCP IP address.  This way the device would be on a static IP address, but I wouldn't need to configure that in the device itself.  After that was done, I proceeded with the following basic networking configuration options..

  1. Browsed to Router -> WAN Setup tab.
  2. Set the HostName to "spa-3102" and Domain to "local".
  3. Set Primary NTP Server to "" and Secondary NTP Server to "".
  4. Enable WAN Web Server was set to "yes" earlier.
  5. Browsed to Router -> LAN Setup tab.
  6. Set Networking Service to "Bridge".
  7. Set Enable DHCP Server to "no".
  8. Click "Submit All Changes" button.

After the device resets, you can verify the settings on the Router -> Status page.  With the basic stuff out of the way, you can move onto the voice options.  These are a little more complicated and you will probably end up tweaking things as you configure Asterisk.

  1. Browse to Voice -> System.
  2. Set the admin password and user password.
  3. Click the "Submit All Changes" button and the device will reset.  Once it does, log in to the device.
  4. Browse to Voice -> Regional.
  5. Vertical Service Activation Codes.  Note: I read a forum post that said to clear all of these out so Asterisk would handle them if entered.  I have not done that yet.
  6. Under Miscellaneous, set the Time Zone.  Note: I still need to figure out the Daylight Savings Time Rule syntax, but I have a couple months for that.  The time zone parameter affects the time that is displayed on your phones if you have phones that do that.
  7. Browse to Voice -> Line 1.
  8. NAT Settings.  Note: I did not need to enable the NAT settings.  If you do, you will need to enable all of the NAT and STUN server settings under the SIP tab as well.  See the Admin Guide for more information.
  9. Set Proxy to your Asterisk server hostname.
  10. Set Register to "yes".  This is the default.  Note: The registration settings initiate contact to the Asterisk server and will keep the connection alive along with some Asterisk settings in the sip.conf file.
  11. Set Make Call Without Reg to "no".  This is the default.
  12. Set Ans Call Without Reg to "no".  This is the default.
  13. Set Display Name to "Line1".
  14. Set User Id to "line1".
  15. Set Password to something secret.
  16. Dial Plan.  Note: I did not modify this, but I may tweak it at some point.
  17. Browse to Voice -> PSTN Line.
  18. Set Proxy to your Asterisk server hostname.
  19. Make sure registration is enabled and required for making and answering calls.
  20. Set Display Name to "PSTN".
  21. Set User Id to "pstn".
  22. Set Password to something secret.
  23. Set Dial Plan 1 to "(xx.)".
  24. Set Dial Plan 8 to "S0<>" where is your Asterisk server.  Note: I believe this hostname needs to match your proxy hostname for authentication purposes.
  25. Set VoIP-To-PSTN Gateway Enable to "yes".
  26. Set Line 1 VoIP Caller DP to "1".
  27. Set VoIP Caller Default DP to "1".
  28. Set PSTN-To-VoIP Gateway Enable to "yes".
  29. Set PSTN Ring Thru Line 1 to "no".
  30. Set PSTN CID For VoIP CID to "yes".
  31. Set PSTN Caller Default DP to "8".
  32. Set PSTN Answer Delay to "5".  Note: This is to allow enough time for caller id.
  33. Click "Submit All Changes" button.

Now your Linksys SPA 3102 should be configured.  The next part involves configuring Asterisk. The installation and global configuration of Asterisk is outside the scope of this blog post. Below are sections of configuration files you need to modify for the SPA-3102.

First, the sip.conf file will handle the connections from the device to the Asterisk server. You should have a global section and most likely have other devices.

; Line1 on SPA3102

; PSTN on SPA3102

Then the extensions.conf file will tell how to route the calls. The "context=internal" for the line1 device above will route those calls to "[internal]". For me that also handles all of my devices. The "context=pstn" for the pstn device will route those calls to the section shown below. Since I put in for dial plan 8 above, we have to describe how to handle those incoming calls below.

exten => 123,1,NoOP(${CALLERID}) ; show the caller ID info in the console
exten => 123,n,Ringing()
exten => 123,n,Answer()
exten => 123,n,Playback(silence/1)
exten => 123,n,Playback(pls-wait-connect-call)
exten => 123,n,Wait(3)
exten => 123,n,Dial(SIP/line1,60)
exten => 123,n,Congestion

Right now all of this is pretty basic just to get things running. I'll probably end up doing more with the extensions.conf file and I plan on signing up with a sip provider to make outgoing long distance calls. The short-term plans are to keep using the local line for incoming calls, but I could port that number somewhere if needed. Also, I need to say thanks to Ryan Tucker for answering all my Asterisk questions along the way!