Asterisk – How to Host a PRI Circuit with a Sangoma Card

These are just a few quick notes of mine on how to host a PRI circuit from a Sangoma card in an Asterisk server to another Asterisk server or wherever for that matter.

This config here is for a Sangoma A102 with two ports and Asterisk will provide the clocking source. Channels 1-23 will be the B channels and channel 24 will be the D channel for signaling. Echo cancelling will be enabled as well.
/etc/dahdi/system.conf

#autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
#autogenrated on 2015-08-28
#Dahdi Channels Configurations
#For detailed Dahdi options, view /etc/dahdi/system.conf.bak
loadzone=us
defaultzone=us

#Sangoma A102 port 1 [slot:4 bus:6 span:1] 
span=1,0,0,esf,b8zs
bchan=1-23
echocanceller=mg2,1-23
hardhdlc=24

#Sangoma A102 port 2 [slot:4 bus:6 span:2] 
span=2,2,0,esf,b8zs
bchan=25-47
echocanceller=mg2,25-47
hardhdlc=48

Continue reading “Asterisk – How to Host a PRI Circuit with a Sangoma Card”

Adtran TA924 PRI Conversion – Routing Inbound DIDs to FXS Ports or via a SIP Trunk to Asterisk and Allowing Bi-Directional Communications Between the Two

I have to say, I’ve worked with the Adtran TA924 Gen1 and Gen2 in the past and thought it was a great product then, but here recently I’ve just rediscovered the amazing flexibility of this unit and I am extremely impressed.

I’ve used the TA924 with a SIP trunk from both a Metaswitch and Asterisk before to convert to analog FXS ports and have had great success. It has always been rock solid but even back when the device was still in it’s infancy stages, it had a few limitations. I remember specifically when the unit could only do a PRI into a PBX and that is certainly no longer the case any more. There doesn’t seem to be anything this unit can’t do at this point. <3

At work, we had around 20 plus regular POTS lines through AT&T and were getting massively raped over the past several years (every year our prices have went up and at the time of porting our numbers out, we were looking at $74 dollars per POTS line and not including usage charges. Effing ridiculous. That is why I hate AT&T and refuse to support them, not to mention all their NSA spying garbage.) and I got a great deal on a PRI through our fiber internet provider so I needed a way to sort of peel out some of the channels into fax lines with DIDs and then bring the rest of the lines into my Asterisk server. In comes my old TA924 Gen2, that was collecting dust on a shelf, to the rescue. Continue reading “Adtran TA924 PRI Conversion – Routing Inbound DIDs to FXS Ports or via a SIP Trunk to Asterisk and Allowing Bi-Directional Communications Between the Two”

Adtran Total Access TA924 – SIP Configuration for Asterisk

Here is a scrubbed working configuration for an Adtran TA924 SIP connection to an Asterisk server with a couple of noteworthy points:

  • The internal feature codes of the Adtran have been disabled with the “voice feature-mode network” command. As long as your Adtran’s internal dialplan supports it, feature codes can be passed through to Asterisk.
  • With the “accept $ cost 0” statement on the “NETWORK” trunk group, the Adtran dialplan simply passes off all traffic to the network.
  • Three way calling has been disabled with the “voice call-appearance-mode single” command.
  • Call waiting has been disabled with the “no call-waiting” command per SIP registration.
  • G711u is the only codec enabled by choice.
  • There is an example of how to connect an FXS port to a SIP user.
  • There is an example of how to set transmit/receive gains on an FXS port.
  • There is an example of how to register an extension range of 7000-7023 to an Asterisk server.

Continue reading “Adtran Total Access TA924 – SIP Configuration for Asterisk”

Cisco SPA500S Excel Sidecar Template

Here is an Excel spreadsheet I found somewhere on the internet and modified to be the exact dimensions for the Cisco SPA500S sidecar (aka the Attendant Console) that works with any of the SPA 5xxG series of IP phones. I’ve even added extra columns to be able to add an extension and a description if you want for each line key button, which is perfect for a call center type environment. All you have to do is fill out the line keys you want on the template, print it out on any 8.5×11 sheet of paper (or any size paper that will fit the cells for that matter), then brush up on your kindergarten cutting skills and you’re in business. Enjoy!
Continue reading “Cisco SPA500S Excel Sidecar Template”

Bash Script – Log Concurrent Asterisk Calls to MySQL and Other Useful One-Liners

Here is a quick and dirty bash script I threw together today to log the concurrent calls for each of my long distance trunks in Asterisk to a MySQL database to be able to quickly analyze usage trends. Sure there is probably other open-source software out there that can do this and give pretty little graphs and what not (cdr-stats or maybe queue metrics come to mind), but where’s the fun in that? As I mentioned, the script is extremely primitive (just the bare minimum as I didn’t have much time to spend on it) and contains no error checking whatsoever but it could also be used as a pretty handy one-liner in bash.

Show all active SIP Calls on a single trunk

asterisk -x "core show channels verbose" | grep "^SIP/yourSIPTrunkName-"

Show concurrent number of SIP Calls on a single trunk

asterisk -x "core show channels verbose" | grep -c "^SIP/yourSIPTrunkName-"

Show all active DAHDI calls on channels 1-24
Continue reading “Bash Script – Log Concurrent Asterisk Calls to MySQL and Other Useful One-Liners”

Bash Script – Convert a Batch of WAV Files to SLINEAR Format for Asterisk Hold Music

Here are a couple of useful one-liners that I picked up from voip-info.org a while back to manipulate a bunch of audio files in a single directory with Sox. You can save yourself some processing power on your Asterisk PBX if all of your hold music is in SLINEAR format that way no transcoding has to take place.
Continue reading “Bash Script – Convert a Batch of WAV Files to SLINEAR Format for Asterisk Hold Music”

Bash Script – An Alternative to Logrotate.d for Asterisk Log Files

For the longest time, I was having trouble getting the log rotate daemon to work properly with Asterisk. I tried using both postrotate and prerotate options on Ubuntu Server and no matter what, I always ended up with dozens or even hundreds of files if I wasn’t keeping a close eye on them. I never figured out why or wanted to spend a ton of time searching for answers but for some reason, the numbering on the log files would always get messed up and it would start adding extra periods on the end of the filenames and everything would get all out of whack.
Continue reading “Bash Script – An Alternative to Logrotate.d for Asterisk Log Files”

Bash Script – Pcapsipdump Spool Directory File Rotation – OR – Rotate Directories Based on YYYYMMDD Format

In the config file for the pcapsipdump program, there is a retention option where you are supposed to be able to enter the number of days to keep the directories in your spool folder and it should auto purge out the old directories/files, however, this option either doesn’t appear to be implemented yet or doesn’t work if you run the app as a different user (could be a permissions issue maybe?).

Anyhow, this script is my solution to the problem. It could also very easily be modified and used where someone needs to search and delete directories that are based on YYYYMMDD format with the ability to whitelist or ignore certain directories, hence the alternate title. Yet another alternate title could even be “Bash Script Functions – Convert YYYYMMDD to Unix Time and Vice Versa” but obviously the script would need modified a little because it has been tailored to fit my needs.

When run as a cron job, the script will grab both the spool directory and the retention period from the pcapsipdump config file and will purge out any old folders based on YYYYMMDD format so they aren’t eating up all your valuable disk space.

I also added a couple of noteworthy user-configurable options. The first being a directory whitelist feature (IGNORE_DIRS array), this option can be used in situations where there are directories that you don’t want purged or would like to keep the data indefinitely and that can also be used in conjunction with the PURGE_ALL feature to delete out any subdirectories that aren’t specifically listed in the whitelist if you are a clean freak.

Download it now – pcaprotate.sh

#!/bin/bash
#
# pcapsipdump file rotation
# By Nathan Thomas
# 12/05/2014
#

### VARS ###
# Location of the pcapsipdump config file
CONF_FILE='/etc/default/pcapsipdump';

# Keep the spool folder clean - Delete all folders (except those in the ignored directories array)
# yes - Keep the spool folder free from any directories not in the ignore list
# no - Don't worry about any other random folders in the spool directory
 Continue reading "Bash Script – Pcapsipdump Spool Directory File Rotation – OR – Rotate Directories Based on YYYYMMDD Format"

pcapsipdump – Dump SIP Signalling and RTP Streams Per Call Leg into Separate Pcap Files

For a VoIP administrator, in order to properly diagnose and troubleshoot issues sometimes, you need the ability to go to be able to go back in time and dig deep within packet traces to get to the heart of the problem. Unfortunately, this means following the NSA’s policy and doing blanket data collection if you can handle the disk storage requirements.

Sure if the problem is easily reproducible, then you can either do a SIP trace in your VoIP software to get just the signalling data or if you need the RTP streams too, you can use “tcpdump” to capture the packets and avoid this scenario altogether but that isn’t always the case and using tcpdump certainly does have it’s limitations.

Capture (pcap) files get huge and harder to work with, you have to create filters to find the data you need, the list goes on and on. Of course, there are some helpful switches you can use to try to get around this when trying to capture data for long periods of time but then you still run into the problem of needing to run the application as a daemon, rotating log files, and then you still have to dig extensively for the data you need.
Continue reading “pcapsipdump – Dump SIP Signalling and RTP Streams Per Call Leg into Separate Pcap Files”

Asterisk Dialplan Module – stdexten

Very similar to the stock version of standard extension in extensions.conf on Asterisk 11 with some minor customizations to the variables passed to it. Technically, this is not what I’m calling a “module” (which is actually a subroutine), this is just an example of the stdexten context which some may find useful.

In my scenario, under no circumstances would there be any reason to have to change the voicemail context, so the arguments that get passed are: The devices to ring, the timeout period (how long to ring the extension), and the destination voicemail box. If neither of the second and third arguments are passed, then it assumes a timeout period of 25 milliseconds and the extension passed in argument one as the voicemail box.
Continue reading “Asterisk Dialplan Module – stdexten”