Trixbox/Asterisk the basics


For those that –still- don't know: Asterisk is an open source PBX (Private Branch Exchange). In other words; you get to own your very own telephony system, just like the big companies.
That is.. if you get it working. Initially this seems intimidating. Especially if you, as I do; come from a Microsoft Windows background.
I had been looking for a good reason to play with Linux for a long time. I had downloaded all the hip distro's (Mandriva, Redhat, Debian and later Ubuntu) and played with them, but never really found a good reason to spend too much of my valuable time on them. Until Asterisk.
Quickly I discovered that the intimidating part was taken away by a distribution called Asterisk@home. Not a very catchy name, espeically if you ever hope to make money from this. The authors of this distribution agreed, and now it's called TrixBox. In fact, although it's still called open-source, this implementation of Asterisk is now sponsored en developed further with company backing: Fonality. The 'public' (free) version of Trixbox is called Trixbox CE and the paid for version is called Trixbox Pro. Both versions are quite alike, with the difference that the Pro version is aimed primarily at stability and is supported by the company. Whereas for the CE version; you're on your own!


I mentioned the intimidating part was taken away: I meant it's a breeze… Asterisk and all kinds of tools you would want are already installed and configured. You hardly have to tinker in the Linux command line interface (yet ;-).
The Trixbox distribution it simply put nothing more than an ISO file (as I hope you know; an ISO is a file based representation of a CD or DVD, most CD burning software can handle these files and create a bootable CD/DVD with them) . Once burned to CD you can boot the Trixbox CD and off you go. Installation of a simple Trixbox system is as mentioned a breeze, the only questions asked is what keyboard to choose, what timezone you're in etc. Mind you, this only sets you up with a PBX that can handle Voice Over IP phones and telecom parties, there's no regular phonelines yet… this is what will make things slightly more difficult, but more on that later.
The Voice Over IP lines are (VIOP) typically use a protocol called SIP. There's more, such as Asterisks own IAX, or H323, or Skinny… For now, we'll stay with SIP, which seems to be the most widely supported standard.

What kind of hardware do you need?
Once the Trixbox ISO has been installed on a system (and you don't need much to get it running; I'd recommend 512Mb and >1.5Ghz CPU, but less specs will work fine) you're ready to start installing the first VIOP phone. I'm pretty happy with my Linksys SPA series, but I hear a lot of people rooting for the Aastra phones also.

Setting this also is not hard, and you'll find more than enough examples and guides on the web on how to do this, so I won't go in too much detail here. First make sure FreePBX has all the modules loaded hat you will need. To do that you might want to start by setting passwords, so first log onto you box from the terminal (root, and the password you provided during installation). Now type Help-Trixbox. The rest is self-explanatory.
You will quickly find that you want to connect from another system to your Trixbox system. An excellent tool for this (and a LOT of other uses) is Putty. It allows you to log on to your server, and is especially handy once you need to start copy and pasting things.

You could argue that Trixbox has two very important components, where the first part is the Trixbox web environment itself, where you do most of the maintenance of the PBX hardware, software, management. Then there's the second part called FreePBX (which is one of the great packages the Trixbox distribution already installed for you). Most if the 'phonestuff' such as creating extensions, setting up routes to the outside as well as inbound calls, creating voicemails, etc. is done here.

To install the phone it basically comes down to this:
Log into Trixbox (using the 'maint' username), go to the FreePBX tab, on the left select extensions
Create an extension, provide it with a 'secret', and configure your phone to have this extension, know the secret and connect to the IP address of your server. Now you're got a phone up and running. If you simply want to test, and don't feel like getting hardware phones right away, simply download the excellent software phone 'Zoiper'
Zoiper used to be names Idefisk (yep, Asterix and Obelix reference; it's the little dog) but for some reason the makers fancied 'Zoiper' a better name. (hmmm.) Zoiper will do IAX as well as SIP, but as mentioned: we'll use SIP for now. Just remember that IAX becomes interesting once you try to get past a firewall or when you attempt to have two Asterisks machines talking to each other.



Am I getting through?
Come to think of it: you probably use a firewall right? And chances are you are using NAT (Network Address Translation). If you're systems are on the 192.168.x.x range, the 172.x.x.x or the 10.X.X.X range you'll be in trouble. Not much, but you will need to make sure your firewall redirects SIP (UDP and TCP port 5060)

On a Cisco this would look like:
ip nat inside source static tcp [your.asterisk.pbx.server] 5060 interface BVI1 5060
ip nat inside source static udp [your.asterisk.pbx.server] 5060 interface BVI1 5060
Where BVI1 is the outgoing interface,
and your firewall needs to be open for those ports also:
permit tcp any host [your.external.ip.address] eq 5060
permit udp any host [your.external.ip.address] eq 5060
Of course this will look completely different on other routers, so your milage may vary. Take a look here for more on NAT and VOIP.

Lets recap: we've now set up the server, we've got phones connected to it. Now we need to be able to call outside! This can be done by using a VOIP provider, and there are lots! For this example I'll be using a local (Dutch) VOIP provider called Budgetphone.nl.
You're need something to call outside, in PBX land this is called a 'trunk', you may have noticed it in the FreePBX menu on the left. First you sign up to a provide you want to play around with, there's quite a few out there that have accounts that don't cost much (no monthly payments, bust just a one-time credit card or paypal payment). Typically this will set you back 10 Euro's, Dollars, Pounds. I use:
www.budgetphone.nl
www.voipbuster.com
www.webcalldirect.com
I prefer budgetphone, as here I also get a phonenumber that I can be called on (the other ones only let you call out) (webcalldirect and voipbuster is actually the same company, but handle different rates for cellphone, so I use them both). For Dutch readers: webcalldirect is 10 cent per minute for mobile phonecalls, where KPN is typically 13 or 14 cents.

Setting up a Trunk
The trick to getting a Trunk to work is first to make sure your firewall is set up correctly, and then to get the settings in your trunk right. Take a look at the bugetphone trunk:


Dial rules tell the phone system what country you're in. As you can see here I'm in the Netherlands (area code 0031). The X's represent a number of digits. Asterisk will change any number according to these rules when dailing out. Check the http://www.voip-info.org pages on details, this website is an excellent source of Asterisk information.
Then there's the trunk name, you'll typically use the providers name here.
Next (and most importantly) you'll get to the PEER details:
allow=g729
context=from-pstn
disallow=all
fromdomain=budgetphone.nl
fromuser=123456789
host=budgetphone.nl
insecure=invite,port
qualify=yes
secret=mypassword
type=friend
user=123456789
username=123456789

(note: you see G729 used here, for now you might want to use ulaw or alaw here instead of G729; more on that later)
Of course the username and password have been changed here, but you'll get the drift.
The next part (User details) we leave empty. Then the last piece to do is getting the registry string right. For Budgetphone this looks something like:
123456789:mypassword@budgetphone.nl/123456789
Now you should have a trunk configured. Wouldn't it be nice if you can actually check if it's there? You can of course. This is where putty (mention earlier) comes in: we'll connect to the server and log on as root. The next command we give is 'asterisk –r'
This lets you look 'inside' asterisk, regular Linux commands no longer apply, you're in Asterisk now. There's a whole lot of commands you can use here to check things (type help for more information) but we are now only interested in whether we have been successful in opening a SIP trunk to budgetphone.nl

First we do a 'sip show peers' (note that after a few letters you can 'tab' to get you the rest of the command, or an overview of commands possible here)
Budgetphone/123456789 81.23.228.150 5060 OK (21 ms)


Since we have told Asterisk that we want 'Qualify=yes' we can also see here that the provider is 21ms away from us. Pretty good.
If you also used budgetphone you will not have the same result here…The reason for this is that (and this only goes for budgetphone) you'll need to change your /etc/host file to make sure your system know budgetphone.nl (didn't you notice the hostname wasn't here in the trunk PEER details? Pay attention! ;-).
Now you could go into the Linux cli, or even use putty, go to the /etc/ directory and then use emacs, nano vi or whatever Linux editor you fancy to add this line to the host file:
81.23.228.150 budgetphone.nl
Let me say a few things about that. I don't know about you, but I tend to use a Vista or XP system for most of my management tasks. Thus it comes in handy if I can also edit my Asterisk PBX files from that system. Again the Trixbox guys come to the rescue by making available a fully configured Samba environment. Samba, as you may know is a package under Linux that makes it possible for Windows machines to access them over the network. All you need to do to get this to work is type 'setup-Samba' (you may have noticed it earlier when you typed help-Trixbox) at the Linux CLI.
Once you've done this you'll be able to simply go to your file explorer and connect to your phoneserver (\\phoneservername) there you'll find a 'share' folder that leads you to the root of the server. If you go to the etc directory here, you'll find the hosts file. Keep in mind that windows ascii and linux ascii is not always the same. Often linefeeds and CR's are used differently between the systems, to avoid messing up configuration files I always use the excellent Notepad++ text editor.
Once this is done you should be able to see that budgetphone is a 'peer'. Any other provider would already have been ok by now.
Another way to check is to enter the command 'sip show registry'. This should show you:

Host Username Refresh State
sip.webcalldirect.com:5060 myusername 105 Registered
sip1.voipbuster.com:5060 myusername 105 Registered
budgetphone.nl:5060 123456789 105 Registered

Anything else would most likely mean that you made an error in the Trunk settings.
Outgoing calls
Now we have a phone system, a phone and a trunk. Lets see if we can get it to call outside! To do that you'll need to setup an 'outbound route' in FreePBX.
Again we take budgetphone as an example. I've made it pretty simple here: if I dial a '444' or if I start with a 7, my phone system will route me through budgetphone. (again; check the voip-info.org website for what you can do with these patterns).
If I wanted to dial through them more; I'd simply make it my default route by putting something like:
00XXXXXXXXXXXX
00XXXXXXXXXXXXX
00ZXXXXXXXXX
00ZXXXXXXXXXX
0[012345789]XXXXXXXX
In there, this pattern would catch most of the numbers I would dial to get anywhere.
You can use these dialing rules to get different things done, mostly you'll be interested in getting the best deal, and where one provider is cheaper to call internationally the other will be cheaper for mobile phones (and typically these numbers will start differently, in Holland for example all mobile phones start with 06). This allows you to use the patterns to redirect certain calls through certain trunks, always getting the best prices!
Below you can see the tunk-sequence. Always make the first trunk the one you –want- the traffic to go over, any other trunks after that are basically fail-safes. If the first trunk doesn't work for example, the phone system will use the next one.
You've now got the basics down, and are able to call outside. Next thing is to receive calls. For this would recommend taking a look at asterisk tutorials Gary has some excellent material online that will get you started there. This post was simply to get you started, and a lead-in to my next article where we will start taking a look at ISDN and how to that that working. All the above information is pretty basic, but I have found that especially the most basic stuff is missing from most tutorials. Simple tips such as 'use notepad++' or 'use putty' are always taken for granted.
From now on the articles will become more in-depth. Promised




موضوعات مشابه: