Linksys/Cisco SPA3102 with Freepbx & BT

This guide works great, with the one amendment; PJSIP Registration should be set to “none”.

https://frag.co.uk/2017/08/14/cisco-spa-3102-freepbx-uk-caller-id/

Critical config info is as follows:

SPA-3102 Configuration

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

FreePBX Configuration

Create a new PJSIP Trunk

  • Trunk Name: <My DID>
  • Outbound Caller ID: <My DID>
  • Maximum Channels: 1
  • Username:  <My DID>
  • Password: password
  • Authentication: Outbound
  • Registration: Send
  • SIP Server: [set to IP address of SPA-3102]
  • SIP Server Port: 5060
  • Context: from-pstn
  • Contact User:  <My DID>  (thanks to Aly)

Inbound Route

  • Set up a default route with Destination as a Ring Group

Outbound Route

  • Route Name: POTS Outgoing
  • Route CID: <My DID>
  • Trunk Sequence for Matched Routes:  <My DID>

More notes:

https://basichelp.sipgate.co.uk/hc/en-gb/articles/206289069-UK-Regional-Settings-Cisco-Linksys-Sipura-Adaptors-

Asterisk Remove Sipgate Alphanumeric ID Extension

Sipgate provide SIP account numbers with alphanumeric sub-accounts. The sub-account extension needs to be removed in order for FreePBX to generate the trunks inbound route.

The following has been added to extensions_custom.conf

[from-trunk-sipgate]
exten => _.,1,Noop(Remove Sipgate Extra Digits)
exten => _.,n,Goto(from-trunk,${EXTEN:0:7},1)

and the following added to the trunks PEER Details

context=from-trunk-sipgate

Ping Watchdog for Strongswan

#!/bin/bash
HOST=$1 ##Host IP at endpoint to test
ConnName=$2 ##StrongSwan connection name to call
OfflineCount=1
while [ $OfflineCount -gt 0 ]
do
echo loop $OfflineCount
ping=$(ping -c 1 -w 2 $HOST | grep bytes | wc -l)
if [[ $ping -gt 1 ]];then
echo "HOST ONLINE"
logger "[vpnwatchdog] host $HOST online"
OfflineCount=0
exit
else
echo "HOST OFFLINE"
let OfflineCount++
sleep 1
fi
if [[ $OfflineCount -gt 9 ]];then
logger "[vpnwatchdog] host $HOST timeout reached. Restarting VPN..."
echo "OFFLINE LIMIT REACHED"
sudo strongswan down $ConnName
sudo strongswan up $ConnName
exit
fi
done