A howto on installing Asterisk with SS7 supported via libss7 on Sangoma hardware along with support for ISUP SAM messages.
After much head banging in bringing up an SS7 link with SAM support, I am documented what worked here.
Firstly, what is SAM support? One end of an SS7 link initialises a new call by sending an Initial Address Message (IAM). All SS7 software stacks support this and usually it’s enough. One case where it’s not enough is when one wants to address a phone number with more than the E.164 standard max length of 16 (usually to pass additional information tacked on the start, end of or even replacing an A or B number). In this scenario, SS7 uses a Subsequent Address Message (SAM) to send the additional digits. Most / all mainstream Asterisk SS7 software stacks do not support this.
The platform and software used is as follows:
Ubuntu 10.04 LTS standard CLI install;
dahdi-linux-complete-2.4.0 from the archives (direct link);
a patched version of libss7 supporting SAM via SVN (see below);
a patched version of chan-dahdi via SVN (see below);
Download and unpack the above referenced add ons package and build and install:
I’m using one of Sangoma’s E1 / T1 interface cards and so I need Wanpipe also. I’m using version 3.5.24 and preceed as follows after unpacking:
cd wanpipe-3.5.24./Setup install
During the install, follow these prompts:
select option 2 => Asterisk/Dahdi Support;
enter path /usr/local/src/dahdi-linux (for Zaptel path prompt);
select defaults for everything else;
you DO want to install start-up scripts;
you DO to configure wanpipe devices for DAHDI;
you DO want to generate /etc/asterisk/chan_dahdi.conf and:
select E1 / T1 as appropriate;
select line framing and encoding;
choose clock source;
select Zaptel/Dahdi – PRI CPE as signalling;
select National ISDN 2 as switch type;
do not enable hardware DTMF detection;
use all channels;
select dial plan context as appropriate;
and continue for other ports as necessary;
finally, choose Save cfg: Stop Asterisk & Wanpipe now
you would like wanrouter to start on system boot;
and you would like to execute ‘dahdi_cfg’ each time wanrouter starts.
We now need to set various options in Wanpipe, Dahdi and Asterisk for SS7 as it’s PRI/ISDN by default.
Edit all /etc/wanpipe/wanpipeX.conf files as necessary and change:
Now edit /etc/dahdi/system.conf and change (for example):
which of course assumes signalling is on channel 1. If you have voice only links, you might need something like:
Lastly, we need to configure Asterisk. Replace lines such as:
;Sangoma A102 port1[slot:4bus:5span:1]
with an appropriate configuration. Mine follows below with some edits and some important notes at the end:
;Sangoma A102 port1[slot:4bus:5span:1]
Set pointcode, adjpointcode and defaultdpc as appropriate;
set networkindicator as appropriate and ensure it matches the other end (you can see what you’re being sent and what you’re sending via ss7 debug;
cicsbeginwith is normally 1 but the telco on my end are starting at 2 – this was groping in the dark diagnostics and issues such as no audio, CICs not in service when both sides claim they are, etc may point to misaligned CICs;
make sure you have configured from-pstn or the appropriate context in yourextensions.conf.
Confirming Your Link Is Up
Now start wanrouter (/etc/init.d/wanrouter start); dahdi (/etc/init.d/dahdi start); and Asterisk (/etc/init.d/asterisk start). You should see your link come up via logs available with the dmesg command. Launch the Asterisk console and check the status of your links:
ast-deg1-1*CLI>ss7 show cics1
CIC DPC DAHDI STATE BLOCKING
You should now be okay to make test calls.
Do You Need Professional Support / Consultancy?
While I will try to respond to comments and questions on this blog, I don’t have the time to provide one on one assistance pro-bono. Professional consultancy on Asterisk and SS7 is available worldwide through my company, Open Solutions with contact details here.
For posterity, I have added Domjan Attila patched libss7 and chan_dahdi to GitHub:
On our own Asterisk PBX server for our office and on some customer boxes with open SIP ports, we have seen a dramatic rise in brute force SIP attacks.
They all follow a very common pattern – just over 41,000 login attempts on common extensions such as 200, 201, 202, etc. We were even asked to provide some consultancy about two weeks ago for a company using an Asterisk PBX who saw strange (irregular) calls to African countries.
They were one example of such a brute force attack succeeding because of a common mistake:
an open SIP port with:
common extensions with:
a bad password.
(1) is often unavoidable. (2) can be mitigated by not using the predictable three of four digit extension as the username. (3) is inexcusable. We’ve even seen entries such as extension 201, username 201, password 201. The password should always be a random string mixing alphanumeric characters. A good recipe for generating these passwords is to use openssl as follows:
Users should never be allowed to choose their own and dictionary words should not be chosen. The brute force attack tried >41k common passwords.
Preventing or Mitigating These Attacks
You can mitigate against these attacks by putting external SIP users into dedicated contexts which limit the kinds of calls they can make (internal only, local and national, etc); ask for a PIN for international calls; limit time and cost; etc.
However, the above might be a lot of work when simply blocking users after a number of failed attempts can be much easier and more effective. Fail2ban is a tool which can scan log files like /var/log/asterisk/full and firewall IP addresses that makes too many failed authentication attempts.
See VoIP-Info.org for generic instructions or below for a quick recipe to get it running on Debian Lenny.
Quick Install for Fail2ban with Asterisk SIP on Debian Lenny
apt-get install fail2ban
Create a file called /etc/fail2ban/filter.d/asterisk.conf with the following (thanks to this page):
Put the following in /etc/fail2ban/jail.local:
Edit /etc/asterisk/logger.conf such that the date format under [general]reads:
Also in /etc/asterisk/logger.conf, ensure full logging is enable with a line such as the following under [logfiles]: