Solved

Configure Linksys SPA3102 trunk for Asterisk 1.8.13.1 on Synology NAS

Posted on 2013-12-17
23
6,930 Views
Last Modified: 2014-01-22
I am trying to set up an Asterisk server on a Synology disk station using a Linksys SPA3102 voice gateway as the trunk to my analog phone line. I have scoured the tutorials and how-to's and have followed the following tutorials with no luck.

http://www.skelleton.net/2012/08/02/linksys-spa-3102/
http://poormanstech.blogspot.com/2007/10/asterisk-trixbox-and-linksys-spa-3102.html
http://lists.digium.com/pipermail/asterisk-gui/2008-September/001313.html
http://www.freepbx.org/support/documentation/howtos/howto-linksys-spa-3102-sipura-spa-3000-freepbx

Asterisk states "Unrecognized trunk" on the System Status page and I get a dial tone but busy signal after dialing.

sip.conf...

[general]
context=default
allowoverlap=no
subscribecontext=default
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
transport=udp
srvlookup=yes
allowexternaldomains=yes
allowguest=yes
allowsubscribe=yes
allowtransfer=yes
alwaysauthreject=no
autodomain=no
callevents=no
checkmwi=10
compactheaders=no
defaultexpiry=120
dumphistory=no
externrefresh=10
g726nonstandard=no
jbenable=no
jbforce=no
jblog=no
maxcallbitrate=384
maxexpiry=3600
minexpiry=60
mohinterpret=default
notifyringing=yes
pedantic=no
progressinband=never
promiscredir=no
realm=asterisk
recordhistory=yes
registerattempts=0
registertimeout=20
relaxdtmf=no
sendrpid=no
sipdebug=no
t1min=100
t38pt_udptl=no
tos_audio=none
tos_sip=none
tos_video=none
trustrpid=no
useragent=Asterisk PBX
usereqphone=no
videosupport=no
disallow=all
allow=ulaw,alaw,gsm,ilbc,h264,speex,g726,adpcm,lpc10,g729,g723,h263,h263p

[authentication]

[line1]
type=friend
host=dynamic
context=internal
username=line1
secret=mypassword
nat=yes
canreinvite=no
dtmfmode=rfc2833
qualify=yes
disallow=all
allow=ulaw

[pstn]
type=friend
host=dynamic
defaultip=192.168.1.226
context=pstn
username=pstn-trunk
secret=mypassword
nat=yes
canreinvite=no
dtmfmode=rfc2833
qualify=yes
insecure=port,invite
disallow=all
allow=ulaw



users.conf...

[6001]
fullname=pstn
registersip=no
host=dynamic
callgroup=1
mailbox=6001
call-limit=100
type=peer
username=pstn-trunk
transfer=yes
callcounter=yes
context=DLPN_Setup
cid_number=6001
hasvoicemail=yes
vmsecret=1234
email=
threewaycalling=no
hasdirectory=no
callwaiting=no
hasmanager=yes
managerread=system,call,log,verbose,command,agent,user,config,originate
managerwrite=system,call,log,verbose,command,agent,user,config,originate
hasagent=yes
hassip=yes
hasiax=no
secret=mypassword
nat=no
canreinvite=no
dtmfmode=rfc2833
insecure=port,invite
pickupgroup=2
macaddress=000E08C328D8
autoprov=yes
label=6001
linenumber=1
LINEKEYS=1
port=5061
requirecalltoken=yes
disallow=all
allow=ulaw,gsm



[trunk_1]

host=dynamic
port=5061
type=friend
qualify=yes
username=pstn-trunk
secret=mypassword
trunkname=1-pstn
context=from-trunk
hasexten=no
hasiax=no
hassip=yes
registeriax=no
registersip=no
canreinvite=no
trunkstyle=customvoip
insecure=port,invite
dtmfmode=rfc2833
incominglimit=1
nat=never
disallow=all
allow=ulaw


Not sure if I'm having Asterisk problems, Synology problems, Linksys problems, or what. So many components in the setup make the issue a challenge. Mainly I need the SPA3102 just operational as a PSTN trunk so I can reach the outside world. The rest of the Asterisk config I can probably figure out easily enough.
0
Comment
Question by:jweickum
  • 10
  • 10
23 Comments
 
LVL 19

Expert Comment

by:feptias
ID: 39751223
If I understand correctly, the SPA3102 would need to register with Asterisk because you have "host=dynamic" in the sip peer definitions. So the first thing to check is if it is registering. You can see this using the CLI command: sip show peers
0
 

Author Comment

by:jweickum
ID: 39752309
SPA3102 will not register with Asterisk, changed "host=192.168.1.226" in users.conf and turned registration off in SPA3102. Trunk status changes to "Request" in red in System Status and CLI: "sip show peers" returns

trunk_1/spa3102            192.168.1.226                                N             5060     Unmonitored
1 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 0 offline]

Check the ports and changed it over to 5060 in users.conf (tried it blank as well since I believe that is the default port)

It looks like now Asterisk recognizes the device as a trunk but will not communicate with it.

Thank you for your help so far.
0
 
LVL 19

Assisted Solution

by:feptias
feptias earned 500 total points
ID: 39753449
You mention the Trunk status changing to "Request" which sounds like some kind of graphical console, but you also talk about editing users.conf. What distribution package are you using?

Please explain how you are configuring the dial plan in Asterisk to make calls with that trunk.

On the SPA3102, use the settings on the "PSTN Line" tab and not the "Line 1" tab because the PSTN Line is associated with the FXO port (labelled "Line" on the SPA itself) which is what you would connect to the Telco's wall socket. Make sure you set "Ans Call Without Reg" to Yes. You will also need to look at the settings under the heading "VoIP-To-PSTN Gateway Setup" as this option will need to be enabled and configured.
0
 

Author Comment

by:jweickum
ID: 39760118
I am using the Asterisk distribution package that comes with the Synology DiskStations. The GUI is Digium, here is the pertinent information from the System Info tab...

Asterisk/1.8.13.1
Asterisk GUI-version : 2.1.0-rc1

I can edit the *.conf files through File Editor, and I can run commands and echo output from the Asterisk CLI tab.

Dial plan is default U.S. rules, every time of day, routing through my "external line" trunk.

I do have "Line 1" disabled now and VoIP to PSTN on, with Proxy set to the IP of the Synology (Asterisk server). Trunk shows "online" but "Unmonitored" still when I run "sip show peers" and "Request" for trunk on System Status page.

Thanks again for the continued support.
0
 

Author Comment

by:jweickum
ID: 39760187
Here is a screenshot of the SPA3102 PSTN line settings in their entirety.

SPA3102 PSTN Line Settings
0
 
LVL 19

Assisted Solution

by:feptias
feptias earned 500 total points
ID: 39760438
In "sip show peers", unmonitored just means that you have qualify=no. I don't know if that is linked to the trunk status showing as Request. Perhaps not. You could try setting qualify=yes to see if it helps, but I suspect it is not important.

To test outbound calls from Asterisk to the PSTN using the FXO port, please change the following on the SPA3102: Under the heading "VoIP-to-PSTN Gateway Setup", set "VoIP Caller Auth Method" to None and set "VoIP Caller Default DP" to 1.

To explain: An INVITE sent from Asterisk to the SPA3102 will no longer be required to authenticate. This makes sense during testing because Asterisk definitions for username on a SIP Peer can be confusing. However, make sure the SPA is behind a firewall and do not allow access to the SIP port on the SPA from the Internet (after all, it only needs to receive SIP requests from your Asterisk box).
The default dial plan for VoIP-to-PSTN should not include an IP address such as you have in DP8. Instead, it should look like (xx.) because it needs to allow simple numbers to be dialled (same as you would dial if using a POTS phone plugged into the Telco's wall socket).
Your DP8 would make sense for inbound calls from the PSTN to Asterisk, but not the other direction.
The setting for "VoIP User 1 DP" is currently set to <none> in the section for HTTP Authenticated users so even if the credentials did match, there is no valid dial plan.
0
 

Author Comment

by:jweickum
ID: 39760890
qualify=yes did the trick in CLI output, but the overall trunk status hasn't changed. I also started over from scratch for the Users and dial plans, in case that was the issue.

Here is the summary page. No dial tone still on the 3102 handset. Not sure what else I can be missing...?

System Status Page
0
 
LVL 19

Assisted Solution

by:feptias
feptias earned 500 total points
ID: 39761473
You said you were using the SPA3102 as a trunk. I assumed you meant that all handsets were connected directly to the Asterisk box and that they should be able to make calls to the PSTN via the SPA3102 using its FXO port to connect to an analogue Telco line.

In which case, the presence of dial tone on a handset connected to the 3102 is not relevant? Please can you provide a diagram. It looks like I was solving the wrong problem.

If you don't have a SIP phone, can you at least test outbound calls using a softphone. You can download free SIP softphone clients for testing - e.g. Zoiper classic, Blink.
0
 

Author Comment

by:jweickum
ID: 39777962
This is the idea...

diagram and goals
0
 
LVL 19

Expert Comment

by:feptias
ID: 39781637
I think you need to have the asterisk server more at the heart of your solution. You mention "phones and lines" (plural), but your diagram shows just one phone and one line so I am still unclear what you are trying to achieve.

Normally, to use Asterisk as a PBX, the handsets all connect to it (either by cable for POTS handsets or through registration for IP handsets) and the trunks connect to it (by cable for analogue/ISDN or as sip peers for IP connections). So asterisk is in the middle. It can route a call from one handset to another or from a trunk to a handset or handset to trunk. This allows it to do all the call routing and also to provide services like voicemail, music-on-hold etc.

An SPA3102 can be used as a gateway allowing you to connect an analogue trunk circuit (labelled "POTS line" in your diagram) to Asterisk without the need to buy a Digium or Sangoma card with an FXO port. The SPA3102 can also be used to connect an analogue POTS handset without the need to buy a card with an FXS port. A single SPA3102 can do both these jobs at the same time, but it is effectively like two independent devices - SIP-to-FXO and SIP-to-FXS. In this role it may be possible to configure failover - for example, in case your Asterisk box does not respond then inbound calls on the FXO port might start to ring the POTS handset. The SPA3102 is surprisingly complex and can do a lot of tricks.

To get the POTS handset working, you will need to configure settings in the Line 1 tab, especially those under the headings "Proxy and Registration" and "Subscriber Information". First, you will need a SIP extension to be defined on Asterisk. You have to give each extension a number and a "secret" or password. On the SPA, in the Line 1 tab set the Proxy field to the address of your Asterisk server and put the extension number and password in relevant fields for Subscriber information. You will need to get the SPA3102 to register with Asterisk.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:jweickum
ID: 39786989
Update:

Following the steps outlined here led to some success.
http://www.fredshack.com/docs/linksys_3102.html

I have Zoiper softphone running on 2 PCs on the same LAN as all of this, attached to 2 extensions in Asterisk, and they can call each other. The lines show up available in Asterisk. I will replace these with actual SIP phones unless there is a simple way to route a single extension back through the POTS line to ring all the regular telephones in an office.

overview screenshot
As you can see, I've re-added the 3102 as a trunk with modified settings based on the "fredshack" config. The "dynamic" host should allow the 3102 to register with Asterisk, and I've triple-checked the ID/pass from the "PSTN Line" tab on the 3102. "Line 1" settings have been mostly removed since fredshack focused on PSTN tab. Not sure if that's correct. Here's my updated users.conf with the trunk settings open.

users.conf screenshot
What I find most interesting is the output of "sip show peers"...

sip show peers
It looks like my sip.conf fredshack settings are allowing a connection on some level but it appears the 3102 refuses to register with Asterisk as a trunk to the outside world, or Asterisk refuses to accept the registration.

I feel like I'm closer, but still hitting a wall. Thank you as always for the helpful info.
0
 
LVL 19

Expert Comment

by:feptias
ID: 39789213
It is a bit confusing having both fxo/fxo and trunk_1/fxo appearing on the list of sip peers. I am not used to working with users.conf. I normally stick to sip.conf or FreePBX format.

What does the SPA3102 report for its own registration status?
0
 

Author Comment

by:jweickum
ID: 39789501
That's the crazy part, it reports as "Registered" for both Line 1 and PSTN.

I have an app on my phone now and the two softphone clients that will all ring as a call comes through our physical phone line. I changed the Dial Plan 1 in PSTN tab to (<:group>S0) so an incoming call dials extension "group" defined in the [internal] context of extensions.conf - which seems to override the Incoming Calling Rules and Ring Groups in the GUI.

Another problem with the Synology Asterisk is that I don't seem to have write permissions to whatever the upload folder is for sound files. From the "Music On Hold" menu I choose either "default" or "general" class and upload a 8KHz mono WAV and get a message that it succeeded but no sound files appear. Just a minor problem by comparison.

If I can successfully dial out to the real world using a SIP phone that will be enough of a complete resolution for me. I think the issue is related to the trunk not appearing as registered in the Asterisk status page, but am not sure how to resolve that, especially if the 3102 thinks it's registered already.
0
 
LVL 19

Assisted Solution

by:feptias
feptias earned 500 total points
ID: 39792456
It makes no sense for the SPA to report that the PSTN Line is registered and for Asterisk to report that trunk_1 Host Addr is "unspecified". I assume you have set 'User ID' and 'Auth ID' to "trunk_1" on the PSTN Line tab (found under the heading 'Subscriber Information'). Please also make sure that you have assigned different 'SIP Port' values for Line 1 and PSTN Line. This is found under the heading 'SIP Settings'.

Also, to avoid possible confusion, in Asterisk please don't set username=fxo for both the Extension and the Trunk. Give them different usernames - it will make things clearer.
0
 
LVL 19

Accepted Solution

by:
feptias earned 500 total points
ID: 39792494
In Asterisk, it would be even better if you did not specify the "username" parameter at all for either the extension or the trunk. This parameter is deprecated. The User ID when registering should match the peer name (the one given in square brackets - e.g. trunk_1). The password on the SPA should match the value for "secret". The only time username might be useful is for the inbound calls - the ones to "group", but even these should be able to authenticate using the name in the square brackets. Alternatively, if you have "insecure=invite" set for the trunk then it will allow inbound calls from the SPA's PSTN line without requiring authentication.

For trunk_1, if you used host=<IP-Address-of-SPA> instead of host=dynamic and you set insecure=invite, then the trunk should work in both directions. However, it looks like the Digium software will not recognise a trunk that hasn't registered. If you were using raw Asterisk, it would work without the trunk having to register.

Does Digium tell you to manually edit the users.conf file or is this something you figured out as a way of making changes? I would expect all changes to be made using web configuration pages. Manually editing conf files when you have a web GUI is generally discouraged for all but the most expert.
0
 

Author Comment

by:jweickum
ID: 39797889
Removing the username in Asterisk and changing username in the SPA's PSTN tab from "fxo" to "trunk_1" helped the trunk--well not exactly REGISTER, but it's not "unrecognized" anymore!  (And it's still registering in the Info tab of the 3102 and appearing OK in "sip show peers."  There were a couple more pieces of the puzzle that resulted in successful calls in and calls out:

-in users.conf, changed "context=spa3102" to "context=internal" (to reflect the fredshack config)
-had to manually add a [trunk_1] context in sip.conf echoing the "fxo" settings from same file

Incoming and outgoing calls seem to be working! One last question, what is the purpose of the "Line 1" tab in the SPA3102? I've been working only in the PSTN tab to make everything work but does Line 1 have any use in my environment? Should I ignore it, is it integral to my configuration and I don't understand how yet, or can it be used to do something additional?

I suspect my answer might lie in these screenshots - the first of which is when I *almost* had everything working (note the "File Editor" option that allows me to reach in and tweak settings that just aren't there in the web interface) - the second screenshot is as of right now where everything works.  Line 1 is registered as "fxo" on the alternate port, I'm just not sure to what end.  =)

sip show peers - almost working
everything works!
0
 

Author Comment

by:jweickum
ID: 39797900
Here is proof that, while not actually saying "registered," at least there is no error for my trunk on the main page!

system status page - trunk is ok
0
 
LVL 19

Assisted Solution

by:feptias
feptias earned 500 total points
ID: 39800005
I suspect trunk1 does not show as registered because the SPA is registering with Asterisk, not the other way around. Typically, a SIP Trunk will need to register from the PBX to the service provider. In your case, the SPA is acting a bit like the service provider.

The Line 1 tab on the SPA is closely associated with the POTS handset that you connect to the green port on the SPA. As I mentioned before, the SPA is almost like two separate units: Line 1 is for the FXS port and allows a POTS handset to send or receive calls over SIP; the PSTN Line is for the FXO port acting as a gateway between a Telco line and SIP. You need to give each one a different port number so they do not get confused (the difference between your two screen shots where it is "almost working" and "everything works" is that you have used different ports 5060 and 5061 on the second shot).

You should be able to use your POTS handset as an extension phone via Line 1 on the SPA3102. It could, for example, register as extension 6003. Then inbound calls from the Telco could first go via the PSTN-to-SIP gateway so they reach Asterisk as a trunk call. Then you could configure Asterisk to ring a group of extensions including 6003 and it should ring the POTS handset on the SPA. The call path is:
Telco --> SPA(PSTN) --> trunk-Asterisk-extns --> SPA(Line 1) --> POTS handset
                                                                                 --> Other SIP extensions
0
 

Author Comment

by:jweickum
ID: 39800480
Fantastic. Thanks so much for sticking with me through this feptias. You've been such a great help and I can't thank you enough!
0
 
LVL 19

Expert Comment

by:feptias
ID: 39800708
You're welcome.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In my office we had 10 Cisco 7940G IP phones that were useless as they were showing PROTOCOL APPLICATION INVALID when started. I searched through Google and worked for a week continuously on those phones, and finally got them working. This is a di…
Article by: user_n
How Sip Phone (User Agent) works and communicates with sip servers 1.  There is a sip server and a sip registrar.  The sip server and sip registrar can be one server or two different servers. The sip registrar is the server on which it is record…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now