How To Configure Asterisk: A Typical Home Asterisk PBX Setup

Now that Asterisk has gone mainstream, more and more Asterisk installations are happening in home environments.

Asterisk is perfect to power a residential phone system, as the cost of entry is now very obtainable, unlike in years past. In fact, you can even run Asterisk on a Linksys WRT54G, along with many many other Linux based embedded devices, allowing for even lower cost of entry and very low power consumption.

In this article, we are going to build a simple, but effective phone system composed of a Digium Analog Telephony Device and Voicemail. We are going to build upon the asterisk configuration from the first installment in this series.

Configuring Zaptel

Download and compile the latest version of Zaptel from the Digium FTP site.

voip:/usr/src# wget
voip:/usr/src# ./configure && make install

We are using the TDM11B, which is 1 FXS and 1 FXO. This provides us with the ability to connect to a regular telephone line (PSTN) and provide dialtone to your existing house wiring.

The Zaptel configuration file is /etc/zaptel.conf.

The first two directives within zaptel.conf are loadzone and defaultzone. You will need to load the appropriate zone for the country you live in.

Available zones are:

* at
* au
* br
* cl
* es
* fi
* fr
* gr
* it
* jp
* mx
* nl
* no
* nz
* pl
* tw
* uk
* us
* us-old
* za

The last two directives in the zaptel file are:


These tell Asterisk to use the appropriate signaling for the two Zaptel telephony interface modules we have on the Digium Card.

Note: Digium has a very specific policy on where they plug in the modules for new hardware. Your channel numbers may be different, depending on where the modules are plugged in. You can determine the channel number and the type of signaling needed by examining the PCI card.

The channel numbers (1-4) start from on side of the card where the telephone cables connect. The green colored modules are Station or FXS interfaces, which need ‘fxoks’ signaling. The red colored modules are Line or FXO interfaces, which need fxsks signaling.

The entire zaptel.conf file:


Zapata Configuration

The Zapata Channel driver configuration file is /etc/asterisk/zapata.conf

channel => 1
channel => 4

Calls from Zaptel channel 1 go to the ‘users’ context and use ‘fxo_ks’ signaling. Calls from Zaptel channel 4 go to the ‘from-pstn’ context and use ‘fxs_ks’.

Notice that we set the context and signaling directives prior to setting the channel. This configuration method allows for very fine grain control over your phone system. Once a value is set, it stays set until you reset the configuration directive. While this fact is not apparent here, once you get into more advanced configurations it will become apparent and appreciated.
Voicemail Configuration

Asterisk’s Comedian Mail application tries to mimic Meridian mail, a popular voicemail platform created by Nortel. However, in my opinion Asterisk’s implementation is more flexible and powerful.

The Voicemail configuration file is /etc/asterisk/voicemail.conf.

serveremail=[valid from address required]
emailsubject=New Voicemail message ${VM_MSGNUM}
emailbody=A ${VM_DUR} long message from ${VM_CALLERID}, on ${VM_DATE}
emaildateformat=%A, %d %B %Y at %H:%M:%S

Here we are informing Asterisk that we wish to record the files using the WAV formats. We are attaching the recording to the notification email. skipms is how many milliseconds we skip when a rewind or fast-forward is requested (by pressing * or # while a voicemail message is playing). maxsilence is how many seconds of silence we allow before hanging up the call. silencethreshold is the threshold value used to assist in detecting silence. 128 is a sane default value. If you are in a high background noise environment you may want to try 256 if you experience trouble with silence detection.

maxlogins allows you to control how many failed login attempts before hanging up. pbxsip=yes drops the [PBX] prefix on the notification email. A valid serveremail or from email address is required. fromstring is the name portion of the From email header.

emailsubject, emailbody and emaildateformat allow you to completely customize the exact content of the notification email. You can see the full details in voicemail.conf.sample, which is in the configs directory of the Asterisk source tree.

100 => 1234,Mark Spencer,

We define the default voicemail context. 100 is the mailbox number and 1234 is the password. Next, we define a name for this voicemail box and then a valid email address where the notification email is sent.
Extension Configuration

The Dialplan configuration file is /etc/asterisk/extensions.conf.

exten => s,1,Dial(${MACRO_EXTEN},25)
exten => s,n,Goto(${DIALSTATUS},1)

exten => ANSWER,1,Hangup
exten => CANCEL,1,Hangup
exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)

exten => s,1,Macro(phone,Zap/1)

exten => NXXNXXXXXX,1,Dial,Zap/4/${EXTEN}
exten => 1NXXNXXXXXX,1,Dial,Zap/4/${EXTEN}

exten => NXXXXXX,1,Dial,Zap/4/${EXTEN}

exten => 911,1,Dial,Zap/4/${EXTEN}

exten => 100,1,Macro(phone,Zap/1)

include => stations
include => long-distance
include => local
include => emergency

Here we define a powerful macro to seamlessly integrate voicemail into the system. As we defined in zapata.conf, calls from the PSTN line go into the from-pstn context, to which we pass onto Zap/1, here our actual telephone handset (or house wiring, if you are hardcore)

The ’s’ extension is the starting extension, since FXO (line) ports do not provide any sort of called number identification , so we simply use ’s’.

The remaining contexts layout a sane dial plan that allows for future expansion and access control.

For example – Lets say you added another FXS port to give your 15 year old daughter her own telephone line, you could add the following to extensions.conf:

include => stations
include => local
include => emergency

Then ensure that the new FXS channel was sent to the ‘teenagers_room’ context (in zapata.conf). This is one effective method control your Daughter’s long distance bill. 🙂

Hopefully this shows you the power you can have at your home. No longer are telephone systems only for the office. With computer technology cost dropping and Asterisk reaching maturity you can, with just a little bit of effort deploy a very powerful phone system within your own home.

Tags: Asterisk, How To, VoIP


One thought on “How To Configure Asterisk: A Typical Home Asterisk PBX Setup

  1. Hmm it seems like your site ate my first comment (it was super long) so
    I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog blogger but I’m still new to everything.
    Do you have any tips for inexperienced blog writers?
    I’d genuinely appreciate it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s