Samuel Tardieu @ rfc1149.net

Asterisk - build your own PBX

,

Several people asked me to describe my home PBX installation, based on the Asterisk Open Source PBX in order to build their own.

Infrastructure

My home network is made of several devices; only those related to VoIP (voice over IP) are represented here:

PBX installation

My home phone line comes from France Telecom, the historical PSTN (Phone Switched Telephony Network) provider in France. When it arrives in France Telecom building (not represented here), my line is splitted in two parts: lower frequencies go to France Telecom equipment for voice processing while higher frequencies are distributed to equipment belonging to Free Telecom, my ADSL provider.

Free Telecom is an innovative player in the ADSL world. They distribute more than IP over ADSL. They have built their own ADSL modem, called the Freebox, which is lended to the clients. The Freebox can not only transport IP over ADSL, it also delivers an independent phone line (which itself uses VoIP internally on the Free Telecom network) as well as television. Not everyone can get television, it depends on the equipment installed by Free Telecom in France Telecom premises and on the line quality. As far as I am concerned, I get around 6Mb/s of download bandwidth and 400kb/s of upload bandwidth.

On the Free Telecom phone line, one can call any French landline number for free with illimited time. Also, the incoming number attributed to you by Free Telecom (you can even choose it) can be called from any France Telecom landline at a local rate, from anywhere in France.

This is all great, but two phone lines (France Telecom and Free Telecom) mean two physical telephones. Two voice mail systems. That’s why I installed Asterisk, a free software PBX system released under the GNU General Public License on one of my computer running the free Debian GNU/Linux operating system.

Hardware

I bought two DIGITX100P cards from DigitNetworks to interface my Asterisk PBX with the physical phone lines. Although the Free Telecom line uses VoIP while in the Free Telecom network, it can only be accessed through a regular phone plug if you use the Freebox. I have seen one report of someone using it directly with a MGCP client with a regular ADSL modem, but in this case you loose the Freebox other benefits such as TV.

Also, I bought two Grandstream Budgetone 100 phones. Those are IP phones; they connect to Asterisk using the SIP protocol. At this time, I only use one of them, I have yet to bring the network into the bedroom to use the other one (although I am not sure this is a good idea to have the network in the bedroom at all).

That’s about everything you need to build your own phone system. If you do not want to buy IP phones, you can either look for FXS interfaces allowing you to use regular phones or use softphones, computer programs that let you phone using a mike and headphones.

Placing an outgoing call

The goal of this system was that anyone could use it while staying at my place. I didn’t want people to do anything special to be able to place a phone call.

If someone dials the phone located on my desk, the phone will transmit the dialed number to Asterisk. Asterisk will first look whether it can reach that phone number using VoIP:

  • if the phone number is registered in the ENUM database, the published route will be used; for example, if someone uses this system with any of my phone numbers, he will automatically gets redirected to my Asterisk PBX without using any phone operator
  • several providers are tried, as some of them offer free call terminations in some countries or for some categories of numbers; for example, if I call a US toll-free number, I get several routes that I can use for free. That means that even from France, I can call US toll-free numbers without paying a dime. Moreover, the callee will not pay anything more than if the call had been placed from within the USA
  • if I really have to, one of my phone lines will be used, depending on their availability and on the number dialed; Free Telecom is often the preferred choice, although at some times in the day it is cheaper to use France Telecom to call French cell phones

The following picture shows (in green) a call placed on the IP phone at my place going out on the France Telecom line.

Outgoing PSTN call

The next one shows a call for which a VoIP route has been located and is being used. The call may reach a real PSTN phone at some other places, or may reach an IP phone if the target user uses VoIP.

Outgoing VoIP call

Incoming calls

Incoming calls can arrive in three different ways: the France Telecom line, the Free Telecom line or using VoIP. My firewall and router box (a lovely Soekris Net4801 disk- and fan-less PC running the free sofware OpenBSD operating system from a compact flash memory card) has been instructed to redirect incoming VoIP packets to my Asterisk PBX. So at the end, incoming calls are handled at the same place and will enter the same processing loop (with different parameters such as an identification of the incoming line).

The Soekris uses OpenBSD packet filter to provide QoS (Quality of Service) over my Internet connection. VoIP packets will get out first as long as there are no more than four simultaneous conversations. After that, the bandwidth will be shared with other applications to prevent a DoS (Denial of Service) attach on my VoIP server.

Depending on the caller ID, different actions may be taken. First of all, if the caller ID is unknown and the call came from the France Telecom line (the only one present in directories), the caller will be presented with a IVR (Interactive Voice Response) system. He will hear some messages asking him to press a certain key on his phone keyboard if he is not a telemarketer. If he confirms, he still needs to type my birth date to get through. Otherwise, Asterisk hangs up. This may sound harsh, but this has not been a problem so far (at least noone told me it was one), and I’ve screened probably many telemarketers phone calls.

Then Asterisk tries to present the call to me. In order to do that, it tries to reach simultaneously:

  • my IP phone at home
  • a VoIP softclient on my laptop, running Lunar Linux
  • any SIP or IAX softphone I could have registered from anywhere

The following pictures illustrates the case where a call comes from the PSTN through the Free Telecom phone line, goes to Asterisk, and goes out using VoIP to a phone registered from a remote location. The red lines show failures to either contact the client or get it to go off-hook.

Incoming PSTN call

Asterisk goodies

Asterisk by being a free software is easily expandable and benefits from a very active developpers community. The software is already excellent but gets better every day.

One feature I use a lot is AGI (Asterisk Gateway Interface), a communication mechanism allowing one to use any programming language to extend Asterisk. A simple textual protocol is used to exchange meaningful information between Asterisk and the module. For example, my whole dial plan logic has been coded using the Python programming language. My DISA (Direct Inwards System Access) is also coded in Python; it allows me to call home, authenticate myself, and do just as if I were there. For example, if I need to call abroad from my cell phone, it is much cheaper for me to call home and redial from there (especially if you consider that I often find free providers for the countries I call much such as the USA).

Asterisk also comes with integrated applications such as a powerful voice mail system (although you can write your own using AGI), DISA, IVR, text-to-speech and so on. Do not hesitate: build your own PBX system; you don’t have to buy any equipment to do that, you can first try to make a full VoIP system using free soft phones. Just do it. But be careful: you may be hooked very fast.

(you can also have a look at this blog entry)

Update: on 2006-05-16, Free Telecom opened their SIP server. It means that it is no longer necessary to use a FXO card with them. Log into your Free ADSL account and configure your SIP account.

blog comments powered by Disqus