Part 1: Asterisk installation and preliminary configuration. Includes making first call to/from the PBX system.
Part 2: Using common features of Asterisk (ie. conferencing, IVR, voicemail, etc).
Part 3: Setting up VOIP and interconnecting Asterisk server (IAX). And once I'm up to speed, writing AGI scripts using Python.
Reminder: Make sure to backup up configuration files before you start working on it. This is 3-part series on how to setup Asterisk PBX system
Okay, first some heads-up. Setting-up Asterisk is as complex as it looks (if not more so). A better sysad/hacker could have done it in few days but it took me almost a month, from the time I started reading the docs to successfully connect to/from the PBX for my first phone call.
What you'll also quickly realize when you start working with Asterisk is that it is actually two set of discipline: Telephony (ie. at least basic knowledge of what FXO/FXS is) and Linux system administration. Actually, that's three discipline if you count on working with the Dialplan which implicitly expect you to have a programming background.
So yes, the entry barrier for learning and setting-up Asterisk from scratch is pretty steep. You can ease the learning curve by using GUI-based Asterisk such Trixbox but there's a trade-off. But actually, you just kept going at it, until you get the hang of it. And then as with most things, it just sink in and becomes straight-forward set-up.
Here's my Asterisk Set-up:
- Dual-core board with 2GB memory workstation.
You can of course use Asterisk on old Pentium-class PC for testing and that is fine if you don't mind the lagged time and general sloggishness of your system (ie. codec processing takes a lot out of your CPU). - 2FXO/2FXS TDM410 Analog Card.
I'm based in Manila where POTS lines is still common in residential areas, if you don't wish to purchase an analog card, you can opt for VOIP connection which is cheaper. I opted for an analog card for a more holistic experience in setting up Asterisk. But I'll probably get a VOIP connection soon.
If you still would like to connect to your POTS line but find the TDM400-based cards a bit pricey, you can get those dirt-cheap X100P/X101P cards from Ebay. But remember, you get what you pay for. And you'd better be an intrepid hacker who's in need of good challenge to make these cards talk. - Distro: Centos 5.3 or newer.
I'm only using 5.3 because I've already have a copy and don't want to bother with the 2 to 3 days download for the latest Centos release.
Also, I prefer Centos/Fedora because of it's yum package management tool and because these are the distros I'm most comfortable with. But use whatever Linux distros that suites you. - Asterisk version 1.6 release
Almost all documentation and tutorial you'll find on building Asterisk recommend that you compile it from the source which is nice really... if you like adding more complexity to an already complex set-up. Make you life easier, use package management tool like yum or apt-get. The time spent compiling (and troubleshooting) your own software is better utilize exploring various features of Asterisk.
- You have a clean Centos installation.
- You are connected to the Internet (for downloading Asterisk packages).
- You have an analog card similar to TDM410 series that is already attached to your motherboard PCI slot.
- Verify that you Linux box is properly detecting your Digium PCI card.
# lspci | grep d161"d161" is the Digium's PCI vendor ID. In addition to vendor ID, it should also show you the Digium card identifier. In my case, that's 8005 for TDM410 Wildcard. - Install the Asterisk packages.
yum -y install asterisk16 asterisk16-configs asterisk16-voicemailSet the Asterisk and DAHDI package to automatically start at boot time.
dahdi-linux dahdi-tools libprichkconfig --level 345 asterisk on
chkconfig --level 345 dahdi on - Edit the /etc/dahdi/system.conf file (make sure that you backup teh config files before editing it). Here's what my config looks like:
loadzone = phIt looks straight-forward right? It's not :-) it's really quite tricky. The 'loadzone' and 'defaultzone' is simple enough. I use 'ph' because I'm in Manila (check zonedata.c for your own country settings). The 'echocanceller' settins are for those who do not have hardware echo cancellers. These cost extra, if you only have hobbyist set-up, just opt for software-based echo canceller.
defaultzone = ph
fxsks = 1-2
fxoks = 3-4
echocanceller = mg2,1-4
The fxsks and fxoks settings is where it gets dicey.
First let's have q quick detour on FXO/FXS (remember, you need to read-up on this topic). FXO (Foreign Exchange Object) is basically any physical 'object' that receive phone services from your local telco. The term 'object' here refers to a phone, a fax, a modem or any objects really that can handle these services.
FXS (Foreign Exchange Subscriber) is basically POTS services delivered from your telco to your phone. FXS provides your phone with a dial tone, battery current, and ring voltage.
Now here is where it gets dicey. For each port on your analog card, you should use the 'signalling' that it correlates to. This of course is the opossite signal.
An FXO port needs to use a FXS signalling. Same goes for FXS port which needs an FXO signalling. So here, a "fxoks = 1-2" simply means that port 1 and 2 is an FXS plug and that we'll use an FXO signal with kewlstart grounding. Gets? No? It's a bit confusing but you'll get the hang of it.
So now how do we determined that a plug is an FXO or FXS (ie. they look identical). The easiest would be to use a DAHDI tool called dahdi_scan. Just run it from the command line. Here's what mine looks like:
Even if you use VOIP, you still need FXS if you wish to use an analog phones which is far far cheaper and more readily available than an IP phone. Yes, you can use 'softphones' but it gets tiring once the novelty has worn off.
Note: Asterisk v1.4 and below uses /ec/zaptel.conf file but the settings are the same. The renaming of configuration files and other zaptel tools was due to trademark issues, Digium decided to rename all zaptel telephony interface into DAHDI (Digium Asterisk Hardware Device Interfface).
Actually, most of the Asterisk tutorial you'll find still refer to the older zaptel.conf and zapata.conf file. As of March 2010, there are very few updated Asterisk tutorial - Edit /etc/asterisk/chan_dahdi.conf file. This is where you'll configure the features and functionality of your card.
Actually, they could have merged this two files into one instead of maintaining two separate configuration files with overlapping settings but where's the fun in that :-)
Include the following in your extensions.conf:echotraining = 800The 'echotraining' specify the time in milliseconds to pre-train the echo canceller. The 'signalling' chooses the signalling method for your FXO/FXS ports. We have 2 'context' settings, this is how Asterisk can determined which context to put incoming/outgoing calls in. Briefly, context is how you would control a call from beginning to end. The value 'incoming' and 'internal' is defined in the extensions.conf, if you did not specify one, it would use the value 'default' (which you still have to defined in the extensions.conf).
;FXS modules
signalling = fxo_ks
context = default
group = 0
channel = 1-2
;FXO modules
signalling = fxs_ks
group = 1
context = outgoing
channel = 3-4
The 'group' settings allows you to roll over your calls. For instance, if you have two telephone lines, you do not have to specify which line to use when picking up the phone to make an outgoing calls, Asterisk will automatically use the first available line. The 'channels' is the actual port where your FXO/FXS is connected.
Note: Asterisk v1.4 and below uses /etc/asterisk/zapata.conf but the settngs are the same. - Edit /etc/asterisk/extensions.conf file.
This is the core of our Asterisk set-up and where we start working with our Dialplan. The extensions.conf is really a rudimentary scripting language for Asterisk, so a programming background is handy. We can use a number of Dialplans applications but for the purpose, we'll just write a couple of lines to have a working Asterisk for routing incoming calls to our analog phone.
Here's my settings:[default]Reload your extensions.conf by running the following command:
exten => s,1,Dial(dahdi/g0)asterisk -rx 'dialplan reload'From another line (or mobile phone) call the number where your Asterisk is hook-up and you should now receive incoming calls!
At this point, you should have a working PBX system that can handle incoming calls! And this calls for some tea!
Note: extensions.ael is a newer and cleaner version of extensions.conf, but since ael is still converted into conf file and there isn't really any compelling reason to shift to ael, stick with extensions.conf file for now.
- Set-up your outgoing calls by editing /etc/asterisk/extensions.conf file.
[globals]Reload your extensions.conf. To get a dial tone, press 9 plus the number you are trying to call. That's it!
PHONE=DAHDI/1
PHONE2=DAHDI/2
OUTBOUNDTRUNK=dahdi/g1
[outgoing]
exten => _9.,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1})
Congratulation! You're very own, kickass PBX system!
Note: We'll gloss over the intricacies of extensions.conf for the moment, and come back to it later on Part 2 of this tutorial.

No comments:
Post a Comment