Configuring asterisk - part 3

April 19, 2018

Calling out through a SPA 3000 ATA

In previous posts, I described the work needed on sip.config and extensions.conf in order to make an asterisk PBX serve my needs, which are as follows:

Figure 1 - asterisk Network
Now I am going to describe how to allow a SIP extension to dial out to the rest of the world via the analog line in my home. With this, I can use my home line to make local (local to home) no matter where in the world I am.

Sipura/LinkSys SPA 3000 ATA

This $25 box is an amazing product. It has so many features that the permutation of configuration settings exceeds many billions. Even though Cisco has stopped producing or supporting this years ago, somehow you can still buy it at AliExpress.

To log in, you must use the id user (not admin). Once in, click Admin Login and advanced on the top right.

First an overview of the product. There are different devices inside the box. Some are acting as a SIP client and some as a SIP server. Unless you are totally clear on what you are doing, it is easy to make mistakes and spend many hours troubleshooting.

If I zoom in on the SPA 3000 shown in Figure 1, it would look something like this:

Figure 2 - SPA 3000
The FXO is a SIP user agent client when it wants to connect calls from the PSTN line to asterisk. The FXO is a SIP user agent server when it receives calls from asterisk to relay out to the PSTN line.

The SPA 3000 also contains a FXS. This allows an analog telephone instrument to be connected. The FXS is totally independent of the FXO. There are many ways of using a phone plugged to the SPA 3000 FXS and I will leave it for a future post.

Most of the FXO interface settings are under the PSTN Line tab in the SPA 3000 admin web site.

My goal now is to allow any of my SIP devices to dial out through the PSTN line. The following channel has to be added in sip.conf:
[SIPURA]
type=friend
port=5080
host=192.168.7.9 ; <=IP of the SPA 3000
SIPURA is just the name that will be referenced later in extensions.conf. You can call it anything. The above means that when a dial plan wants to connect to the SIPURA channel, asterisk will connect to the device specified in host on port 5080. The device, the SPA 3000, then has to be configured to listen on port 5080. See later on this.

The next step is optional for making outgoing calls, but we will do it anyway as it will be needed later for taking incoming calls on the SPA 3000. Create an extension in sip.config/sip_custom.config for the SPA 3000's PSTN Line to register with asterisk:
[7000]
secret=***password here***
context=from-SIPURA
dtmfmode=rfc2833
host=dynamic
type=friend
qualify=yes
In the SPA 3000 admin advanced site, go to the PSTN Line tab and make the following settings:
  • At the top, set Line Enable to yes.
  • SIP Settings, SIP Port: 5080. It must match the port setting under the channel [SIPURA] in sip.conf. This is the device acting as a user agent server.
  • Proxy and Registration, Proxy: IP address or resolvable name of the asterisk PBX.
  • Proxy and Registration, Use Outbound Proxy: MUST BE no, otherwise audio won't go out. I don't know why.
  • Proxy and Registration, Ans Call Without Reg: If no then the PSTN Line must be first registered to the asterisk like in extension 7000 declared above. If set to yes, the 7000 extension registration is not required. (Note that the field is "Ans Call" and not "Make Call".)
  • Subscriber Information: User ID: 7000 and Password: as in the definition for channel 7000 in sip.conf above, if registration is desired.
  • VOIP-To-PSTN Gateway Setup, VoIP-To-PSTN Gateway Enable: Yes. This will enable calls coming in by IP to go out via the analog line.
  • VOIP-To-PSTN Gateway Setup, VoIP Caller Default DP: none. This will make the device just dial the number passed to it unmodified.
The final step is to create the dial plans so that people can call out via the SPA 3000. Add the following to extensions.conf under the [from-internal] section:
[from-internal]
exten = _NXXXXXXX,1,Answer
exten = _NXXXXXXX,n,Dial(SIP/SIPURA/${EXTEN},300)
exten = _NXXXXXXX,n,Hangup
Decoded, the above means whenever an extension with the from-internal context dials a seven-digit number with the first digit not 0 or 1, asterisk is to dial the SIPURA channel and pass along the number dialed. The N pattern means a single digit in the range 2 through 9.

That's it! You should now be able to dial out using the analog phone line connected to the SPA 3000. Adjust the dial plan number pattern to suit your locality. Remember to be careful with toll or international numbers that might incur charges.

Next, I will describe how to configure to allow incoming calls on the analog line to be routed to the asterisk network.

Comments

Popular posts from this blog

Things that go missing