The CISCO (or even Netgear) SPA-3102 was a Voice Gateway device, used to convert between the POTS (Plain Old Telephone System) and a VOIP server. The device is very much end-of-life, and although not sold new, is widely available and still very popular.
There are many online guides for using the SPA-3102, but since it can be used in many countries and with many different platforms, it can be quite different to get working. Even with a UK guide, I found it impossible to follow them to set up with recent versions of Asterisk, and even when they did work, the device could not pass on Caller ID. This guide is possibly also suitable for the SPA-112 and with Asterisk and other Asterisk-based PBX platforms.
This guide concentrates on the configuration and arrangement between SPA-3102 and FreePBX. It assumes your device is already configured for your LAN network and for the UK Telephone network. If this is not the case, reset your device or check the manual and the configuration below
What is working:
- Making calls from a VOIP device or softphone, via FreePBX to the SPA-3102 as an outgoing trunk
- Making calls from an attached analogue telephone to the SPA-3102 and using this as to make VOIP calls via FreePBX
- Receiving incoming calls from the SPA-3102, and forwarding them to FreePBX, including using Ring Groups, Voicemail, and Caller ID
- Sending and receiving faxes
What is not working:
- Nothing known
Quick Tips
There’s a lot of misinformation online about what you should and shouldn’t do. To clear some of these up;
- Do use a proper UK telephone cable, as short as possible and with all four wires connected (I have had problems with 2-wire and 3-wire extensions).
To quickly see if things seem okay, whilst on-hook, in the Admin > Advanced > Voice > Info screen, the PSTN Hook State should be On (not Ringing!), and line voltage should be around 50V. - You do not need to use the WAN socket for your LAN as some advise. The VOIP ports are available on both. The device can even act as a NAT and DHCP server (only the right way around!).
The only minor annoyance is that there’s no LED on the front for LAN, only for WAN. - Use PJSIP, and use the same username for both sides. Set FreePBX to Send Registration and Authenticate going Outbound.
Troubleshooting
To quickly check everything is in order; on the Admin > Advanced > Voice > Info screen, the PSTN Hook State should be On and the Line voltage should be around 50V.
If not, your cable is likely faulty or missing wires.
If your telephone is constantly showing that a message is waiting, under the Admin > Advanced > User 1 menu, under Supplementary Service Settings set Message Waiting to No.
We are authenticating the SPA-3102 using IP address for calls coming in from the Landline, rather than Auth ID. This is because the SPA-3102 will use the Caller ID as the Auth ID for incoming calls, and this causes authentication to fail. This should be solved with the Remote-Party-ID, but this doesn’t seem to allow auth with FreePBX.
If you see the error WARNING[14004] res_pjsip_registrar.c: AOR 'pstn_fxo' has no configured max_contacts. Endpoint 'pstn_fxo' unable to register, this appears to be only set in the Asterisk config in FreePBX when registration is being received. Asterisk requires max_contacts for registration with sending too, or this error occurs. I was not able to fix this with pjsip.aor_custom.conf as expected.
As a temporary fix, adding the appropriate max_contacts array element $conf['pjsip.aor.conf'][$tn]['max_contacts'] = 1; should solve this. This needs to be set on both sides of the conditional (the first is for send/none, before the else, and should already be set for receive) on line 63 (in newer versions this is line 444) of /var/www/html/admin/modules/core/functions.inc/drivers/PJSip.class.php.
This should look as follows (thanks to Aly for spotting this):
if ($trunk['registration'] == "send" || $trunk['registration'] == "none") { $conf['pjsip.aor.conf'][$tn]['max_contacts'] = 1; if(!empty($trunk['aor_contact'])) { ... } } elseif ($trunk['registration'] == "receive") { $conf['pjsip.aor.conf'][$tn]['max_contacts'] = 1; }
SPA-3102 Configuration
Configuration is really straightforward here – we’re using the same username and port on both Line 1 and the PSTN Line;
Admin login > Advanced > Voice > Line 1:
- Line Enable: Yes
- SIP Transport: UDP
- SIP Port: 5160
- SIP Remote-Party-ID: Yes
- Auth Invite: Yes
- Proxy: [set to FreePBX IP]
- Register: Yes
- User ID: pstn_fxo
- Auth ID: pstn_fxo
- Use Auth ID: Yes
- Password: password
So what we’ve done here is to set the Line 1 (i.e. the analogue telephone connected to the SPA-3102) to allow to register as a VOIP device to the FreePBX server. This lets you make calls from the telephone to the VOIP server.
Admin login > Advanced > Voice > PSTN Line:
- Line Enable: Yes
- SIP Transport: UDP
- SIP Port: 5060
- SIP Remote-Party-ID: Yes
- Auth Invite: Yes
- Proxy: [set to FreePBX IP]
- Register: No
- User ID: pstn_fxo
- Auth ID: pstn_fxo
- Use Auth ID: Yes
- Password: password
- Line 1 VoIP Caller DP: None
- PSTN Caller Default DP: 1
- Dial Plan 1: (S0<:pstn_fxo@192.168.0.181>)
Including brackets – and where 192.168.0.181 is your FreePBX IP
Yes, both the same settings except for the SIP Port. It’s possible even that can be the same.
We are authenticating the SPA-3102 using IP address for calls coming in from the Landline, so registration is not needed. This is due to the Caller ID as above.
FreePBX Configuration
Create a new PJSIP Trunk
- Trunk Name: pstn_fxo
- Outbound Caller ID: Your landline telephone number
- Maximum Channels: 1
- Username: pstn_fxo
- Password: password
- Authentication: Outbound
- Registration: Send
- SIP Server: [set to IP address of SPA-3102]
- SIP Server Port: 5060
- Context: from-pstn
- Contact User: pstn_fxo (thanks to Aly)
Inbound Route
- Set up a default route with Destination as a Ring Group
Outbound Route
- Route Name: POTS Outgoing
- Route CID: Your landline telephone number
- Trunk Sequence for Matched Routes: pstn_fxo
- Dial Patterns: You can add any patterns you like here, whether with or without prefix=9 (which will be removed). Anything matched (which is not an extension) will be sent through the landline.
Complete!
Apply the settings and restart/reload Asterisk. Now monitor the asterisk.log file, and check the registration time in the SPA-3102.
The SPA-3102 should indicate:
- Line 1
- Hook State: On
- Registration State: Registered
- Next Registration In: 0 s
- Message Waiting: No
- PSTN Line Status
- Hook State: On Line
- Voltage: 49 (V)
- Loop Current: 0.0 (mA)
- Registration State: Not Registered
You should now be able to make calls from your softphone via the FreePBX Trunk and out through the PSTN line.
Any landline incoming calls should be redirected via the ring group, and all devices should ring.
You should also be able to make calls from an attached telephone to the SPA-3102, and it should act like a normal VOIP telephone.
If you have any problems, please do leave a comment below or get in contact!
Below I’ve put together some technical information on the exact configuration used;
FreePBX Configuration Files
If you are configuring Asterisk by hand, these may help:
pjsip.aor.conf
[pstn_fxo]
type=aor
qualify_frequency=60
contact=sip:pstn_fxo@192.168.0.180:5060
max_contacts=1
# Note - Replace 192.168.0.180 with IP Address of SPA-3102pjsip.auth.conf
[pstn_fxo]
type=auth
auth_type=userpass
password=password
username=pstn_fxo
# Note - remember to set a secure password
pjsip.endpoint.conf
[pstn_fxo]
type=endpoint
transport=0.0.0.0-udp
context=from-pstn
disallow=all
allow=ulaw,alaw,gsm,g726,g722
aors=pstn_fxo
outbound_auth=pstn_fxo
send_rpid=yes
send_pai=yes
dtmf_mode=autopjsip.identify.conf
[pstn_fxo]
type=identify
endpoint=pstn_fxo
match=10.8.8.180pjsip.registration.conf
[pstn_fxo]
type=registration
transport=0.0.0.0-udp
outbound_auth=pstn_fxo
line=yes
endpoint=pstn_fxo
server_uri=sip:192.168.0.180:5060
client_uri=sip:pstn_fxo@192.168.0.180:5060
# Note - Replace 192.168.0.180 with IP Address of SPA-3102UK Telephone Configuration
With thanks to http://www.aoakley.com/articles/2008-01-08.php
Admin login > Advanced > Voice > Regional:
Dial tone: 350@-19,440@-22;10(*/0/1+2)
Ring back: 400@-20,450@-20;*(.4/.2/1+2,.4/2/1+2)
Busy tone: 400@-20;10(.375/.375/1)
Reorder tone: 400@-20;10(*/0/1)
SIT 1 tone: 950@-16,1400@-16,1800@-16;20(.330/0/1,.330/0/2,.330/0/3,0/1/0)
MWI dial tone: 350@-19,440@-22;10(.75/.75/1+2)
CWT1 cadence: 30(.1/2)
CWT2 cadence: 30(.25/.25,.25/.25,.25/5)
CWT frequency: 400@-10
Ring 1 cadence: 60(.4/.2,.4/2)
Ring 2 cadence: 60(1/2)
Ring 3 cadence: 60(.25/.25,.25/.25,.25/1.75)
Ring 4 cadence: 60(.4/.8)
Ring 5 cadence: 60(2/4)
Time Zone: GMT
FXS Port Impedance: 370+620||310nF (or 270+750||150nF )
Caller ID Method: ETSI FSK With PR(UK)
Daylight Saving Rule: start=3/-1/7/1:0:0;end=10/-1/7/2:0:0;save=1:0:0Admin login > Advanced > Voice > PSTN Line:
PSTN Disconnect Detection
Detect CPC: yes
Detect Polarity Reversal: no
Detect PSTN Long Silence: no
PSTN Long Silence Duration: 30
PSTN Silence Threshold - High
Min CPC Duration: 0.09
Detect Disconnect Tone: yes
Disconnect Tone - 400@-30,400@-30; 2(3/0/1+2)International Control
FXO Port Impedance: 270+750||150nF
OnHook Speed: 3ms (ETSI)
Current Limiting Enable: yes
Ring Validation Time: 256ms
Ring Indication Delay: 512ms
Ring Timeout: 640msAdmin login > Advanced > Voice > Line 1:
Auto PSTN Fallback: Yes
Dial Plan:(x.<:@gw0>)
Emergency Number: 999
Hello! great, finally i have a Spa3102 working with Freepbx!
All works, incoming calls and outgoing calls through pstn line, but i have only a problem, on incoming calls i can’t saw the number of the caller, i saw always pstn_fxo.
Have you got a solution for this?
Thanks a lot
Hi Giampietro,
Fantastic, that’s great to hear! It is really tricky getting Caller ID to work.
I think the SPA3102 sends the CallerID as the Auth ID (i.e. the username) when authenticating.
I had to switch mine over to use the IP address to authenticate, then the Caller ID should be passed through to FreePBX.
I don’t have mine set up at the moment but that hopefully should help!
Good luck! 🙂
Dug
Very shortly this website will be famous amid all blogging and site-building viewers,
due to it’s good articles
Almost got things working but not quite! Inbound trunk appears to be working fine but the analogue phone connected to the line port is still not working for me.
This error appears in my asterisk logs “WARNING[6828] res_pjsip_outbound_registration.c: Fatal response ‘501’ received from ‘sip:192.168.40.2:5060’ on registration attempt to ‘sip:pstn_fxo@192.168.40.2:5060’, stopping outbound registration” (192.168.40.1 is my SPA3102). 501 is “not implemented” as far as I know, so I don’t know why it’s throwing this.
On the SPA I have the line 1 SIP port configured as 5160 and the PSTN line port as 5060 as per your instructions. If I change the Line 1 SIP port to 5060 I get the following error “WARNING[9864] res_pjsip_outbound_registration.c: Fatal response ‘404’ received from ‘sip:192.168.40.2:5060’ on registration attempt to ‘sip:pstn_fxo@192.168.40.2:5060’, stopping outbound registration”. I’m a little confused as to the port configuration as your instructions say “Configuration is really straightforward here – we’re using the same username and port on both Line 1 and the PSTN Line;” but then gives different ports?
Thanks for the excellent guide – I hope you can get me over the final hurdle!
Hi
thanks a lot for this guide and its really helps.i have setup all the settings as above but my Hook State: On Registration State: Failed. do u know any idea that i can get this sorted please..
hi , I follow your instructions but Line 1 vstill shows failed,,,but I can make outside calls…my freepbx still use legacy sip on port 5060,,so I adjust the pstn port 5060 to 5161..Im a correct ??
I think you want legacy SIP, 5060 should be the correct port to connect to
Hi thanks for replying,,anyway I disable legacy sip driver and im using pjsip only,,so I can set 5060 default port for pjsip..
but still same logs:
res_pjsip_outbound_registration.c:1012 handle_registration_response: Fatal response ‘501’ received from ‘sip:10.48.5.253:5060’ on registration attempt to ‘sip:pstn_fxo@10.48.5.253:5060’, stopping outbound registration
Sorry jefbuan, it’s been a long time since I’ve used this!
If this is the pstn trying to register, I don’t think that’s necessary. I was “authenticating the SPA-3102 using IP address for calls coming in from the Landline, so registration is not needed. This is due to the Caller ID as above.”
You might also want to see this post which has the same error and seemed to be resolved that way:
https://community.freepbx.org/t/linksys-spa3102-low-line-voltage-on-pstn/58384/11
There also might be additional error messages in your logs following this one!
Hope that’s some help! – Dug