Configuration File Common Options

Each protocol has its own specific options, but they share a number of options common across files. Let’s
go over a few common tasks and the options that control them that you’ll likely run into when editing
configuration files.

Users, Peers, and Friends
Asterisk uses some peculiar classifications for its VoIP connections.They are classified by the type= setting
which is either set to user, friend or peer.These are often accompanied by little to no explanation, which is a
 shame because they’re actually quite simple.
A user is a connection that will be used to make telephone calls to the local server; a peer is a connection
that will be used to make telephone calls from the local server; and a friend is a connection that will be used
to make telephone calls both to, and from, the local server.
These classifications are most commonly used in IAX2 and SIP connections. However, using them in SIP
connections is actually starting to become redundant due to how SIP connections are normally set up.We
will cover that later in the chapter.

Allowing and Disallowing Codecs
Asterisk supports numerous codecs for audio. Codecs can save bandwidth and allow for more simultaneous
phone calls on a data link. For a big list of the codecs Asterisk supports, refer to the table in Chapter 1.
Codecs are configured via the allow and disallow directives. Disallow can be used to explicitly deny use of
specific codecs, or it can be used in conjunction with allow to grant the use of only specific codecs.
Confused yet? Let’s look at a common situation: Say your shiny new Asterisk server has a connection to
your telephone provider via the IAX2 protocol. However, whenever a phone call is made through the
provider, the GSM codec is used, rather than the ulaw codec that is used when you call between extensions in the office.This needs to be fixed. So opening up the iax.conf configuration file you add the following line to the section controlling the connection:
                     disallow=gsm
Then issue a reload command to Asterisk. Problem solved, right? Not necessarily. While yes, this will
disallow use of the GSM codec, the behavior that results might not be the one expected.The added line tells
Asterisk not to use GSM; however, it still has the option of picking from all the other codecs it supports.The
correct way to ensure ulaw is used as the codec would be to add the following lines to iax.conf.
                   disallow=all
                   allow=ulaw
Now, if you’re scratching your head at the disallow=all statement, don’t worry. While, yes, that directive
essentially tells Asterisk to disallow every codec from being used, it is followed by the allow=ulaw
statement, which tells Asterisk that ulaw is okay to use. Essentially, those two lines are the same as typing
out disallow statements for every codec Asterisk supports except the one you want to use. When receiving
a phone call, Asterisk will check each allow and disallow statement to see which codecs it can and cannot
 use. It will first see the disallow=all statement, stopping the use of all codecs, but then it will allow the ulaw
codec once it reads the allow=ulaw statement. This can be expanded to work with multiple codecs as well.
If you wanted to allow both ulaw and alaw,ulaw European equivalent, the same steps would be followed,
except this time there would be two allow lines, allowing both ulaw and alaw.


Configuring Your Connections

Connections are what make Asterisk useful. If there are no connections to Asterisk, you wouldn’t be able to
 connect a phone or use a link to the outside, which really limits the things you can do with it. Asterisk, when
first installed, actually has a connection to a demonstration server hosted by Digium.This connection shows
how calls can be transferred via VoIP to a completely different server as easily as dialing a number, and
gives you a taste of what can be accomplished.This connection, however, is a nice demonstration, but
doesn’t really have any use besides showing off what can be done with Asterisk. If you want to actually
accomplish tasks, you will need to set up your own connections with the outside world.

Connections, Connections, Connections!
Numerous files control the various protocols for Asterisk. Some protocols are commonly used in today’s VoIP setups, while some are quite vestigial and are likely not to be used unless you have specialty hardware. Let’s take a look at the various protocols supported by Asterisk (see Table 3.5).
Each protocol is controlled by a different file. Multiple connections can be set up in a single file, or the files
can be broken down and linked via include statements. What you opt to do is a choice of personal
preference. Each file has certain specific configuration options that are used only for the protocol the file
governs, and they also have options that are common across all files. Let’s go over some of the conventions:

Configuration File Conventions
All Asterisk configuration files have certain conventions that run throughout them. We went through some of them when we were talking about extensions.conf. However, some differences exist in the terminology and layout when comparing extensions.conf to another file.
Much like how extensions.conf is broken down into contexts, most configuration files are broken down into sections. Context and sections have the same syntax— namely, that the headers are surrounded by brackets, as shown in the following example.

Each configuration file often has a [general] section as well, which functions more or less the same way as
the [general] section in extensions.conf: settings in that section are applied to each section unless they are
overridden within the specific section.


Configuring extensions.ael

The alternative to extensions.conf is extensions.ael. extensions.ael is extensions.conf written in a scripting
language called Asterisk Extensions Language (AEL). AEL is language maintained by Digium solely for
writing dial plans in Asterisk. While it is functionally equivalent to extensions.conf,AEL is syntactically much
more powerful and allows for greater flexibility in simple scripting and logical operations. If you’re familiar
with scripting in other languages, AEL can often be easier to pick up than the regular  extensions.conf syntax  extensions.ael can be used as a replacement for extensions.conf or have both used side by side.
extensions.ael is not in widespread use in today’s installations. However, due to its greater functionality, it
would not be surprising to see extensions.conf depreciated in future versions of Asterisk in favor of
extensions.ael.

Using AEL to Write Your Extensions

Everything that can be written in extensions.conf can be rewritten in extensions.ael. Let’s take our simple example from Example 3.1 and rewrite it into AEL.

Execution-wise this does the same exact thing Example 3.1 did. Asterisk answers the call, starts playing the
mainmenu sound file while waiting for the caller to enter digits.The caller can then either enter 100 and be
connected to the channel SIP/10 or 200 and be connected to the channel SIP/20.The caller is then hung up
on when the menu stops playing. Notice how, despite being mixed up a bit, there are still contexts,
extensions, and variables. In this case, however, the exten => EXTENSION, PRIORITY,
COMMAND (ARGS) syntax is completely scrapped. In extensions. ael, the exten => is removed, along
with any use of priorities. extension.ael followsmore of a line-by-line execution pattern the way
extensions.conf executes when the n priority is used. While this simplifies things so you don’t have to worry
about making sure every extension has the right priority, it provides a lack of flexibility in execution order
and Goto() statements. Let’s see what happens when we rewrite the code in Example 3.2.


Because we can’t specify the exact step to jump into in the s context, we need to create a label in the s
extension to tell the Goto() statement where to enter.The restart: label in the s context is the where the t
and i extensions jump to when they are done executing.This label needs to be explicitly specified within the s
context because there are no steps numbered within the context. Macros also function much in the same way
 they do in extensions.conf.They are set up as if contexts, but have extra variables that can be passed to
them. In AEL, variables passed to the macro are not referred to as ${ARG1} through ${ARGX}. In AEL
you can assign them local variables names, which cuts down on the confusion factor when trying to
remember which values are assigned to a certain variable. Another difference in AEL is that the Macro()
command is not used when calling a macro. Instead, the macro’s name has an ampersand added in front of
it. Let’s add the std-exten macro to our AEL example to see how it fits in.


AEL is a very powerful language that allows for a much cleaner dial plan. It is still in heavy development, and may change in future Asterisk revisions, so it may not be quite ready for production yet. However, it is a very good idea to learn the mechanics of it because Asterisk may move toward it in the future.

Writing Macros

include-ing (other contexts within the current one is a handy way to save lines of code and duplication of code. Another easy way to increase efficiency and decrease code duplication is through Asterisk’s macro abilities. Macros can be described as special contexts that accept arguments.They allow for more flexibility than contexts, and allow common tasks to be automated and not repeated. In our previous examples, if someone dialed an extension, it rang a channel. It would continue ringing the channel until someone picked up, or the call terminated. What happens if we want to have that extension drop to voice mail playing the user’s “I’m not here” message after 20 seconds of ringing, or playing the user’s “I’m currently on the phone” message if the phone line is busy?
Yikes.That got complicated quickly. Can you imagine having to set that up for multiple extensions? A single typo in the various extensions could suddenly have people’s voice mails intended for one person wind up in someone else’s voice-mail box. Plus, the various extensions would get out of hand very quickly; your extensions.conf could start topping over thousands of lines of code. Let’s insert a Macro to tame this beast.The macro, macro-stdexten, is included in Asterisk by default for this exact reason.
Using the macro allowed us to write a single piece of code that would duplicate the function of the code in
the previous example. It’s also modular, allowing for the easy addition of extra extensions and extra voice-
mail boxes.The stdexten macro takes two arguments:The first being the channel to ring, and the second
being the voicemail box to send the call to if the channel is busy or does not answer.The macro rings the
channel for 20 seconds and then sends it to voice mail telling voice mail to use the unavailable message. If
the channel is busy, it immediately sends the caller to voice mail, telling voice mail to use the busy message if
the user has one. If there is some other condition on the call, like if the phone cannot be found on the
network, the macro sends it to voice mail with the unavailable message. The Macro() command takes at least one argument, the macro name.You can also pass multiple arguments to the macro by calling the
Macro() command with additional arguments. In our example, macro- stdexten takes two arguments: the
channel to ring, and the voice-mail box to call. Upon calling the macro, the macro is executed like a normal
context, with the exception of extra variables ${ARGX}, where X is 1 through the number of variables you
passed to the macro. This takes care of incoming calls, but what about phones on the inside dialing out
Setting these up is as simple as setting up another context. Each time you set up a connection, you need to
specify which context calls coming from that connection will go into. Setting up a context in which calls can
use your outside line and then assigning all internal phones into that context will allow the phones to send
calls via the outside lines. Continuing our example, let’s set up a context for internal calls:

[internal]
exten => _1617NXXXXXX,1,Dial(Zap/1/${EXTEN})
exten => _1310454XXXX,1,Dial(IAX2@/mass:Sk5S@cali.conglomocorp.com/${EXTEN})
exten => _1NXXNXXXXXX,1,Dial(IAX2/conglomocorplogin@IAXProvider/${EXTEN})
exten => _011X.,1,Dial(SIP/SIPProvider/${EXTEN})
exten => 100,1,Macro(stdexten,10,SIP/10)
exten => 200,1,Macro(stdexten,20,SIP/20)

Let’s go over what each line accomplishes. Each one shows a different way of composing a dial command.The first line tells Asterisk that if a user dials a telephone number in the 617 area code, it will match the _1617NXXXXXX wildcard and the phone call will be sent out via the fist Zaptel device.The next line matches anything within the 310-454 prefix and will connect to a server called “cali.conglomocorp.com” with the username “mass” and the password “Sk5S” and send the phone call through them.This is an explicit connection created in extensions.conf. If a user dials a U.S. telephone number that isn’t in 617 or 310-454, it will match the _1NXXNXXXXXXX wildcard, and will be sent via the IAXProvider connection, which would be created in iax.conf. Finally, if a user dials an international number beginning with 011, it will match the _011X. wildcard and be sent via the SIPProvider connection, which would be created in sip.conf. Also, the user can dial either of the two extensions on the system and be connected to them directly.These extensions would already be connected in sip.conf.
It is important to note that if we placed the _1NXXNXXXXXXX wildcard above the _1617NXXXXXX wildcard or the _1310454XXXX wildcard, anything below the _1NXXNXXXXXX wildcard would never be used since the _1NXXNXXXXXXX wildcard would match everything. Asterisk reads lines from the top down and will match the first line it sees. Remembering this can save you a lot of headaches, and depending on your setup, possibly some money.


Including Other Contexts within the Current One

It’s important to note that when creating another context, the settings and extensions from one context do not propagate to another. Setting up these extensions over and over again can be tedious and will lead to a duplication of code and effort. Thankfully, Asterisk permits other contexts to be joined together via the include => directive.This allows other contexts to be include-ed into the current context and act as one giant context. Let’s go back to our example.The t and i context are duplicated in both the [default] and [supportmenu] contexts.With a couple of small changes, we can make a separate context with just the t and i extensions and include => them into both contexts.
Okay, pop quiz time. Did you notice the difference between this example and the previous one? Don’t
worry if you didn’t, it’s pretty subtle. Because we are including the same t and i context between two files,
the same code will be executed between both. Namely, they will be going to step 1 of the s extension in
 both contexts. Previously in the [default] context, the t and i extension went to step 2 of the s extension,
bypassing the Answer() command. What does this change? Not a single thing. Technically, you’re adding an
extra step every time a caller times out or enters an invalid extension, which may affect performance if this
happens repeatedly in a very high-traffic environment, but, in the grand scheme of things this extra step will
not be perceptible. Answer() only answers the call if the call is in an unanswered state. It ignores being
called if the call is already in answered.


Contexts, Extensions, and Variables! Oh My!

extensions.conf can be broken down into three major parts: contexts, extensions, and variables. Each has their own unique and important function and needs to work together for a good dial plan to function.

Contexts
To put it simply, contexts are the fences that keep your extensions from getting tangled up in a big mess. A context is a simple way for grouping extension commands based on what the user has dialed.To begin a context, put the name of a context by itself in square brackets. Each context then contains a list of commands. In extensions.conf there are two special contexts called [general] and [globals] in which
certain settings can be set. general has a few special settings that define how extensions.conf behaves. First off is the static setting.This, can be set to either yes or no, but for some reason, only yes has been implemented.This will eventually control Asterisk from rewriting the extensions. conf every time an extension is added or deleted.The next setting is writeprotect. This can also be set to either yes or no, and this controls the ability of someone at the CLI to rewrite your dial plan via the save dialplan command.This may seem handy, but doing so will delete all comments in the file. Each extension follows a similar syntax. exten
=> EXTENSION,PRIORITY,COMMAND(ARGS). exten => precedes every extension.This is a
directive that tells Asterisk to define an extension, as opposed to a context.The next three parts of an
extension are EXTENSION, PRIORITY, and COMMAND(). Let’s cover these three portions.

Extensions
Extensions can be broken down into three types: a constant extension, a wildcard extension, and a special extension. A constant extension is an extension that when coded to a literal constant is the dial plan. A wildcard extension is a context that uses wildcards to match multiple possibilities for the extension.Wildcards can be either internal Asterisk wildcards or RegEx-like patterns (see Table 3.2).

So with Wildcard extensions, it is simple to reroute numerous extensions with one line of code. Let’s say a
department in your building, the ever-important widget department, have moved to another division and
wanted to leave a message at their old extensions informing callers that they had moved.They previously
occupied Extensions 300 through 329 on your PBX. Rather than rewrite 30 lines; you can add
a single extension of

           exten => 3[0-2]X,1,Playback(WidgetDeptHasMoved)

This will have any caller dialing the department’s former extensions greeted by a message informing them of
the move. Playback is a command that plays back a sound file stored on the system; we’ll cover it and its
counterparts later. In addition to wildcard and literal extensions, there are also special extensions that

correspond to special events in the dial plan (see Table 3.3).


Extensions do not necessarily need to be numbers either.They can be made with any type of text. While extensions like “fuzzybunnydept” cannot be dialed by a caller if included in your context, it can be used internally by your dial plan.We’ll see how this can come in handy later in the chapter.

Priorities
PRIORITY controls the flow in which commands are executed. For each extension, this is either controlled by an increasing number or a special n syntax.The n syntax tells Asterisk to execute the extension one line after the other:

[incomingcall]
exten => s,1,Answer()
exten => s,n,Playback(mainmenu)
exten => s,n,Hangup()

In this example, any call being routed to the “incomingcall” extension in Asterisk would have its call answered, a menu would then play, and then the call would be terminated. After Asterisk finishes executing one line, the next line would be executed. Numbering the steps provides greater flexibility with the dial plan since it is possible to control the flow logically rather than line by line. For example, the extension shown earlier could be rewritten with a numbered sequence

[incomingcall]
exten => s,2,Playback(mainmenu)
exten => s,1,Answer()
exten => s,3,Hangup()

Asterisk still answers, plays the menu, and hangs up because it executes by line number rather than by the order in which the lines appear. It executes step 1, followed by steps 2, and then 3.These steps could be scattered throughout the context and intertwined with hundreds of extensions. As long as they are numbered correctly, Asterisk will execute them in order for that context.

Dial Plan Commands
The commands are the heart of any dial plan.They are what actually cause Asterisk to answer the call, ring the phone, transfer the call, play the menu, and do numerous other things. See Table 3.4 for a look at some of the more common ones.


Variables
Variables in extensions.conf are nothing special.They act like variables in any other language.Variables are set via the Set() command and are read via the variable name encased in ${}:

[example]
exten => s,1,Set(TEST=1)
exten => s,2,NoOp(${TEST})

Variables are common in simple dial-plan applications and Asterisk uses certain variables for internal functions, but their use is somewhat uncommon in regular dial plan usage.

Tying It All Together
All of these pieces of dial plans make little to no sense when thinking about them in the abstract, so you may be scratching your head right now. Let’s take a look at how all of these would be used in an everyday environment, by looking at a simple extensions.conf:
When a call enters the [default] context, it is answered by Asterisk. Asterisk then starts playing the
 mainmenu sound file while waiting for the caller to enter digits. At this point, the caller can either enter 100
and be connected to the channel SIP/10 or 20 and be connected to the channel SIP/20. If the menu finishes
playing and the user has not entered any digits, the call will be hung up on.

Using Special Extensions
Now, hanging up on your caller if they wait to listen to the whole menu seems kind of rude, doesn’t it? So
let’s take the file we had before and use some special extensions to have the menu replay if the user hasn’t
entered an extension and inform them if the extension they entered is invalid.


That’s much nicer. Now the behavior of the dial plan is the same, up until the main menu ends. At that point,
the menu repeats. Also, now if the caller dials an incorrect extension, the dial plan will play a menu that
informs them the extension they entered is not valid.

Creating Submenus
Normally, most small to medium-sized companies only require a single menu, but let’s say your boss wants
to have a support menu that allows customers to direct their questions to the appropriate support group.We
can accomplish this by creating a second context that contains the appropriate menu and extensions. Let’s
build on the previous example again and add a second menu that allows callers to be connected to the
Blivet,Widget, or Frob support lines.
In this example, we’ve added a third option to the main menu. If a caller dials 3, they are connected to the [supportmenu] context with a Goto() statement. Goto() can be called many different ways.You can jump between priorities in the same extension by just specifying Goto(priority) or you can jump between extensions in the same context by specifying Goto(priority,extension). Lastly, you can switch contexts by specifying Goto(context, extension, priority).

Configuring Your Dial Plan

The dial plan is the logic behind how phone calls are routed through your Asterisk installation. Asterisk runs
every incoming call, every outgoing call, and every call in between extensions through the dial plan logic in
order to determine where it should go and whether or not it should be completed.The dial plan is contained
in extensions.conf,and therefore it can be said that extensions.conf is easily the most important configuration  file in Asterisk. Removing extensions.conf is similar to removing a traffic light at a complicated intersection; cars will want to enter and cars will want to leave, but there will be no way to direct them. extensions.conf is a bit more complicated than a typical configuration file. On top of the usual sections and settings, there is a logical flow similar to a program. Essentially, extensions.conf is one giant script.The sooner you keep this in mind, the easier it will be for you to write a good dial plan.

Configuring Asterisk

Figuring Out the Files
If you enter into your Asterisk configuration directory, /etc/asterisk, you’ll see 62 files by default. If you’re
taking over a previous installation administered by someone else, you may see more than that. Looking at
the file names, you’ll see they have cryptic labels like rtp.conf, or file names that seem to be the same thing,
like asterisk.adsi and adsi.conf. When trying to configure your system, finding the right file to edit can be like
unearthing the proverbial needle in a haystack. (See Table3.1 for information on what each file controls.)
To say Asterisk has a lot of settings would be an understatement of mammoth proportions. While this is a
lus when you want to tweak Asterisk to fit your needs exactly, it is a bit overwhelming. However, don’t fret.
Certain configuration files can be ignored if you don’t have certain hardware, and other files can be ignored
 if you do not need to enable certain features of Asterisk.

freePBX with TrixBox

freePBX is accessed by clicking the Asterisk link of the main menu, and then clicking the freePBX link.
freePBX will greet you with a welcome screen and a list of menu options on the top. From here you can
access the setup options, system tools, call activity reports, Flash Operator Panel, and the Asterisk
 recording interface. Clicking Setup will take you to the setup main page.The main page has a list of options
on the left, which will allow you to administer user accounts, extensions, and general Asterisk settings;
configure dial plans; and set up and control inbound and outbound trunks. See Figure 2.15.

PHPConfig
PHPConfig is a great way to edit configuration files without having to deal with a shell terminal. It allows you
 to edit files just like they were in a text editor, but without having to learn how to use a Linux shell. It
provides the best of both worlds. PHPConfig can be accessed by clicking the Asterisk link on the
maintenance home page and then clicking the Config Edit link. Afterward, PHPConfig lists all the files in the
Asterisk configuration directory. Clicking the name of one of these files brings the file up in an edit
window.To the left of the edit window, PHPConfig lists all the sections it reads from that file, allowing you to
quickly jump to and edit the section you wish to work on. When finished editing, click the Update button
below the edit window. PHPConfig will then write the file to disk.The changes are not immediately reflected
in Asterisk though.To reload all the configs, you will need to click the Re-Read Configs link at the top of the
page.This tells Asterisk to perform a “reload” command that will reload all the configuration files. If there are
no errors, PHPConfig will then display “reset succeeded.” See Figure 2.16.
Installing Asterisk from Scratch
Before there were live CDs and distributions, there was source code. Asterisk’s availability of source code
 is one of its biggest features, allowing anyone to “poke under the hood,” see the internal workings, and
rewrite portions if needed. Compiling Asterisk from its sources gives you the greatest amount of control as
to what files are installed, and where they are installed. Unneeded options can be removed entirely, allowing
a leaner Asterisk install. However, as always, there is a downside. Compiling anything from source is
intimidating if you aren’t used to doing it. However, it’s terribly once you figure it out.

The Four Horsemen
When compiling Asterisk from source, there are four major pieces to the puzzle: LibPRI, Zaptel, Asterisk-
Addons, and Asterisk. Asterisk is, you guessed it, the PBX itself.This package contains the code for
compiling the PBX and all its modules.You aren’t going to get far compiling Asterisk without this package.
LibPRI is a library for handling the PRI signaling standard.The PRI standard was created by the Bell System
back in the 1970s and is now an ITU standard. LibPRI is a C implementation of the standard.This package
may be required depending on the hardware installed on the system. Asterisk-Addons is a package that
contains certain optional “bells and whistles,” such as an MP3 player so Asterisk can handle sound files
encoded in MP3, and modules for logging calls to a MySQL database. While these modules are completely
optional, they are good to have, especially the MP3 player, and the resources they take up are minimal.
Installing them is recommended. Zaptel is the package that contains the driver and libraries for Asterisk to
talk to Zapata telephony hardware, which are the telephone interface cards discussed earlier. This is a handy
package to install, even if there is no Zaptel hardware on the system, since the conferencing software
requires it for timing purposes.

Asterisk Dependencies
Before you start compiling Asterisk, you must make sure you have all the requirements satisfied. First off is
the compiler. If you don’t have a compiler like GNU C Compiler (gcc) installed, you aren’t going to get very
 far compiling the source code. Next, make sure you have the libraries required to compile, otherwise you
will likely have some kind of odd error at compile time. Asterisk has three dependencies: ncurses
(www.gnu.org/software/ncurses/), a library for text-based “graphical” displays; OpenSSL
(www.openssl.org/), an open-source library of the TLS and SSL protocols; and zlib (www.zlib.net/), a data
compression library. Asterisk requires both the library itself and the associated include files.These are
included automatically if you compile from source. However, if you install the libraries from a binary
repository, you will need to include the development packages as well. For instance, you would need to get
both zlib and zlib-devel.

Getting the Code
Links to all of the Asterisk code are available at http://www.asterisk.org. Clicking the Downloads tab will
take you to a page with links to grab all the necessary files.The links to get Asterisk provide options for
downloading either Asterisk 1.2 or Asterisk 1.4 directly, or visiting the source archive. Grabbing Asterisk
directly only downloads the Asterisk package, so you’ll want to download the LibPRI, Zaptel, and
Asterisk- Addons separately.The latest versions of each package should end in -current. Since there are
multiple source archives, it is best to put all of them in a common subdirectory wherever the system’s source
code directory is located (for example: /usr/local/src/asterisk/). See Figure 2.17.

Gentlemen, Start Your Compilers!
Compiling is simpler than one might think. Often, all that’s required is three commands: ./configure, make,
and make install. Once you have these three commands memorized, you’ll do fine.

Compiling LibPRI
The first step is to compile LibPRI.This is required if you have a PRI interface hooked into the system, but optional if you do not. First, expand the archive.
     tar xvzf libpri-1.4-current.tar.gz
This will expand the source archive into a directory. At the time of this writing, itis libpri-1.4.0/. After the file
is done expanding, change to the LibPRI directory. cd libpri-1.4.0/
LibPRI doesn’t have a configuration command yet, so the only two steps are to compile it via the make
command, wait until it finishes, and then run make install. It is important to run the make install command as
a root user, otherwise the library will not be installed correctly due to permission errors. Once everything is
done, you can exit the LibPRI directory. cd ../


Installing Asterisk TrixBox

Four Linux distributions focus on Asterisk: PoundKey, a Linux distribution supported by Digium; Evolution
PBX, a distribution made for small businesses with commercial support; Elastix, a distribution supported by
a commercial company; and trixbox. trixbox was released in 2005 as “Asterisk@Home,” a simple and easy
way to install Asterisk on a computer. Self contained within a bootable CD, Asterisk@Home focused on
ease of use and ease of install, allowing someone with little to no Linux experience to start playing with
Asterisk. In 2006, Asterisk@Home was acquired by Fonality, a California-based VoIP services firm, who
renamed the new version of Asterisk@Home to “trixbox.”Today, trixbox is one of the leading Asterisk
Linux distributions. With over 30,000 downloads a month, it takes its place among the “heavy
hitters” of Asterisk distributions. The trixbox CD contains numerous add-ons to Asterisk: freePBX, a Web-
based configuration manager; HUDLite, a cross-platform operator panel; and SugarCRM, a complete
Customer Relationship Manager suite. All of these are configured to run out of the box with trixbox,
allowing a complete suite of tools for managing and maintaining your Asterisk installation.

Getting trixbox
trixbox is available at www.trixbox.org.The most up-to-date version at the time of this writing is trixbox 2.0
which contains Asterisk 1.2.13.The download size clocks in at a hefty 550MB, so you may want to put on
a pot of coffee before you start downloading. Like the live CD’s discussed earlier, the downloaded image
can be burned with the “image burn” function of any standard CD recording program.
Booting trixbox
After burning the trixbox CD, use it to boot the machine you will be installing to. Again, as mentioned in the
 earlier “Booting SLAST” section, the computer may need some kind of setting changed to boot from a CD.
Once the CD is booted, the trixbox boot screen is displayed, as shown in Figure 2.8.

After about five seconds, the CentOS installer will start loading up, as shown in Figure 2.9.
After all the system’s hardware is detected, the installer will start prompting you for questions regarding
keyboard layouts and time zones. Answer these as appropriate to your system. Once done with that, it will
prompt you for a root password. Once enough information is gathered, the installer will start formatting your
hard drive and the installation will begin, as shown in Figure 2.10.

The trixbox installer will copy files, reboot, and begin to install specific packages on the system (see Figure
2.11). After installation, trixbox will reboot one last time and display a login prompt. Log in with the
username root and the password you specified in the setup process and you will be presented with a root
shell. After logging in, the URL of the Web management interface will be displayed, as shown in Figure 2.12.


Configuring trixbox
trixbox, like SLAST, should configure its network automatically if there is a DHCP server on the network. If
it didn’t, or if the DHCP address is not the address you want for the server, you can run the netconfig utility
to manage network settings, as shown in Figure 2.13.
netconfig will prompt you for the IP address, netmask, gateway, and nameserver of your network. Enter
these as appropriate for the system. After confirming these settings, the utility will exit. Reboot the system,
and the new network settings will take effect.

trixbox’s Web Interface
One of trixbox’s nicer features is a Web interface that allows you to manage the system through a Web
browser. It uses PHPConfig Asterisk config editor, which allows you to edit the files directly, in addition to
using freePBX, which is a standardized interface for managing certain Asterisk features.
By entering the system’s IP address into your Web browser, you’ll be greeted with trixbox’s home
page.You’ll see links for the system’s Asterisk Recording Interface which manage the ability to record audio
conversations on Asterisk, scripts to manage Asterisk’s recordings, voice mail, and call monitoring
recordings; the MeetMe management system, a system to manage MeetMe conferences; Flash Operator
Panel, a phone operator panel for Asterisk written in Flash; and SugarCRM customer relationship
management software. In the upper right, you’ll see a link to switch into “Maintenance” mode. Clicking the
link will prompt you for a username and password. Log in with the username maint and the password
password.

The trixbox management system is very full featured, and a book could be written on these two systems
alone, so let’s just take a (very) quick tour of the two major configuration editors on the system:The
PHPConfig Asterisk config editor and the freePBX system. Figure 2.14 shows the trixbox system default
page.

Installing Asterisk SLAST

So, you’ve purchased your server, installed an operating system, and you’re ready to plunge head first into
Asterisk. Determining the “right way” to install Asterisk depends on your situation. If you just want to try
Asterisk out and are worried about messing up an existing system, the Live CD would likely be your best
route. If you are not too familiar with Linux installation, but are looking to set up a dedicated Asterisk
system, you may want to look at a CD distribution of Asterisk. If you are an experienced Linux
administrator and want to configure Asterisk to fit into a custom environment, you’ll likely just want to
compile it from scratch. Finally, if you are either a Mac OS X or Microsoft Windows user, and you just
want to use your existing operating system for an Asterisk install, you’ll likely just want to use the packages
for your operating system. Asterisk’s ability to be customized isn’t just limited to the final setup; it starts at
the installation phase of the system.You can easily make it fit almost any environment.

Using an Asterisk Live CD
Live CDs are bootable CDs that contain a complete operating system. After booting, your machine will run
the operating system from the CD without installing it to the hard drive. If something goes wrong, you can
turn off the computer, eject the CD, reboot, and boot back to the operating system installed on your hard
drive. Although this installation method is not recommended for most production environments, it is a perfect
 way for a novice user to try out the features of an operating system without altering the boot machine in any
way. In this section, we’ll take a look at one of the more popular live Asterisk CDs: SLAST.
    SLAST
       SLAST (SLax ASTerisk) is an Asterisk-ready version of the Slackware-based SLAX
       Live CD. Maintained by the Infonomicon Computer Club, SLAST was designed to
       help educate people about the advantages of Asterisk and allow them to set up a
       simple Asterisk server in the easiest way possible.
    Getting SLAST
      SLAST is available at http://slast.org.The ISO image is available from their download
      page.The download size comes in at just a bit over 100MB, so any broadband
      connection should make quick work of the download. Once the ISO is downloaded,
      the disk image can be burned to a CD using the “image burn” feature of most popular
      CD recording programs.
    Booting SLAST
      Booting SLAST is as simple as inserting the CD into an Intel-based machine, and
      rebooting. Depending on how your machine is configured, you may need to press a
      key during startup to instruct the machine to boot from a CD. Once the CD is
      booted, the SLAST screen is displayed, as shown in Figure 2.4.
      Once SLAST loads the system into memory, the login screen is displayed.The
      login screen has a quick “cheat sheet” of sorts showing file locations of Asterisk configuration
      files, Asterisk sounds, Asterisk modules and the SLAST documentation.
      The root password is also displayed. Log in with the username root and the password
      toor, and you will be presented with a root shell, as shown in Figure 2.5.


Configuring the Network
While a network connection isn’t specifically required for Asterisk, unless the target system has hardware to
connect it directly to a phone, some kind of network connection will likely be necessary if you want to
connect to something besides the local computer. SLAST, as with most live distributions, does a pretty
good job at detecting any and all hardware on the target system. If everything is plugged in and turned on,
SLAST should have no issues setting up the hardware. However, SLAST, like other Live CDs, may have
trouble detecting networks settings. If you’re running a DHCP server, Asterisk should automatically
configure your settings. However, if manual intervention is required to configure these settings, you may need
to rely on ifconfig, the InterFace Configurator. Running ifconfig without any arguments will display any
configured network interfaces on the system. Ethernet interfaces will be shown labeled by their abbreviations
 ethX, where X is a number starting at 0 for the first interface. Next to the name will be fields for the IP
address labeled as “inet addr,” the broadcast address labeled as “Bcast,” the network mask labeled as
“Mask,” along with various statistics regarding the interface. See Figure 2.6.


The configure_network script allows the system’s network interface to be configured with minimal user
interaction.The user can run the script by entering configure_network at the prompt and pressing Enter.The
script will execute, prompting you for information regarding your desired network configuration, as shown in
Figure 2.7.




Setting Up Asterisk

Choosing Your Hardware
One of the first things to do when setting up Asterisk is to figure out your hardware needs. Hardware is a bit
of a catch-all term and refers to the server, the phones, and the connections between them.There is no
standard ratio for Asterisk that dictates “To support A calls over a B period of time, you need a server with
X megabytes of RAM, a processor faster than Y, and a hard drive bigger than Z” or that “If you are in a
call-center environment, X brand phones is the best choice.”To figure out what is the correct fit for your
situation, research is required.

Picking the Right Server
Picking the right server is a key decision when running Asterisk.The last thing a company wants to hear is
 that their phone system is down. Asterisk can run on obsolete hardware, but you will get what you pay for.
Reliable, capable equipment is the foundation for any reliable, capable PBX system.

Processor Speed
Processor speed is the most important feature when looking at a server to run Asterisk.The more processing
power, the more responsive the system will be when it is placed under heavy call loads. Asterisk runs well
on any modern processor, handling moderate call loads without any issue. However, this does depend on
how the system is configured to handle calls.

Transcoding and Protocol Translation
Transcoding is when the server is handling a conversation that is coming in with one codec and coverts it on-
the-fly to another.This happens a lot more than thought, as most VoIP telephones transmit in μ-Law, which
is the standard codec for telephone conversations. If the server is using the GSM codec for outbound calls,
it needs to “transcode” the conversation and convert it from μ-Law to GSM.This, by itself, is pretty simple;
however, when the server starts having to transcode multiple conversations simultaneously, more processing
time is required. If a performance bottleneck develops, the conversations will start to exhibit delays in the
conversation, more commonly referred to as “lag.” Protocol translation is the same problem as transcoding,
except instead of converting the audio codec, it needs to translate the protocol used.This is also common
with VoIP providers who only offer access to their networks via specific protocols.

RAM
RAM usage on Asterisk is pretty low. Asterisk can easily fit within a 64MB footprint even on a fairly large
install. Since Asterisk is modular, trimming RAM consumption is as easy as removing modules from the
startup sequence.A bare bones Asterisk startup can fit within a memory footprint of fewer than 30MB.

Storage Space
Storage space is probably one of the least important choices when choosing a server for Asterisk. Hard
drives keep getting larger and cheaper with each passing month, allowing even a low-end computer to have
massive amounts of space. Asterisk, by itself, hardly takes up any room; however, when voice prompts for
Interactive Voice Response (IVR) menus and voice mail start being added to the system, Asterisk’s
footprint starts growing. Hard drive size needs to be determined by the amount of users on the system and
the amount of voice mail expected.
While this may not seem like a lot at first, consider that a person can average about five voice mails a day in
a busy office. If each of those messages is about a minute each, and there are 100 people in the office, that’s
500MB of storage per day!  When you calculate the math per year, we’re talking almost 13GB! Plus, other
factors exist as well. Let’s say a team leader sends a five-minute group message to his or her team of ten
people.That 5MB message just copied across the system into ten separate mailboxes consumes 50MB.
Also, don’t forget to factor in saved messages, people on extended absences, and group mailboxes that
may be accessed by the public. Asterisk, like any high-demand server application, benefits from Redundant
Arrays of Independent Disks (RAIDs). RAIDs are very important in any kind of high-availability environment.

Picking the Right Phones
Phones are arguably the most important part of a PBX setup.This is how most users interface with the PBX
system. Picking the proper phone is key to a successful PBX deployment.There have been instances where
users were ready to give up on Asterisk solely because they hated their phones.Thankfully, changing phones
is easy and these users quickly changed their opinions once new phones were installed.

Soft Phones
The easiest phone to set up with Asterisk is a soft phone.A soft phone is a computer program that emulates
a phone on your PC. Soft phones are easy to set up and can be configured in a matter of minutes.They’re
usually very easy to use, often displaying a telephone-like interface on the screen. Soft phones utilize the
computer’s sound card for transmitting and receiving audio, or optionally a “USB phone,” which is a phone
like device that plugs into the computer’s USB port. Soft phones are inexpensive (often free) and USB
phones generally cost less than $50.USB phones sometimes can help, but they usually aren’t geared for a
business environment. In addition, these users are tethered to a PC. If the PC crashes, no phone calls.

Hard Phones
The alternatives to soft phones are hard phones—the phones we’ve used the past 125+ years: a physical
device that sends and receives telephone calls. Hard phones are on the opposite side of the spectrum from
soft phones: they’re expensive and often harder to set up than their software counterparts. However, most
users prefer a hard phone; it’s what they’re accustomed to. The most common hard phones include IP
phones: analog phones connected to an Analog Terminal Adapter (ATA) and analog phones connected via
interface cards.

IP Phones
IP phones are one of the most common solutions you’ll see for VoIP in a business environment.They plug in
to an Ethernet connection and emulate a regular analog phone.They’re made by numerous companies,
including Cisco Systems, Polycom, Aastra, and Siemens, just to name a few.The price and quality of these
phones run the gamut, but the general rule of “you get what you pay for” applies here. In today’s market, a
good IP phone will cost you at least $150 per unit, like the Cisco 7960 IP Phone

Analog Telephone Adapters
ATAs are the bridge between the world of analog telephones and the world of VoIP. They are small
devices, usually in the form of a small plastic cube, with a power port, one or more telephone jacks, and an
Ethernet port. An analog phone connected through an ATA can participate in phone calls on a VoIP
network. ATAs are cheaper then IP phones, mainly because they are slightly simpler.ATAs are often
offered by the same companies that make IP phones and range in price from $50 to $100 depending on
the protocols they support, the number of ports, and, of course, the number of features. Some ATAs have
 both a port for a phone and a port for an outside phone line, allowing a quick and easy way to interface
Asterisk with both your phone and the public switched telephone network. ATAs work with most phones,
the exceptions being proprietary phones from digital PBXs and older rotary dial phones. Digital phones are
nearly impossible to support due to their complexity and the differences between one manufacturer and
another. Rotary phones aren’t supported by most ATAs because most developers consider, somewhat
correctly, that pulse dialing is an obsolete protocol.

Who’s Using Asterisk?

Asterisk really started to make a splash on the Internet in late 2003 when it became fairly stable and early
adopters started to pick up on VoIP. Since most early adopters were hard-core technophiles who were
looking for a program that was free or cheap, and could be easily configured to do everything from the
simple and the mundane to the downright odd, Asterisk was in the right place at the right time.To say it
caught on like wildfire is a bit of an understatement. Today, Asterisk is still very active within the hobbyist’s
realm. Small groups are setting up Asterisk servers for both public and private use, one of them being the
Collector’s Net previously mentioned.There are also groups of phone phreaks— people who hack on the
telephone network—who are taking the leap into the digital realm, setting up projects such as Bell’s Mind
(http://www.bellsmind.net) and Telephreak (http://www.telephreak.org). For phone phreaks, the ability to
run a telephone system in the privacy of one’s own home is just as exciting as when the first personal
computers became available to computer hackers. Not only is Asterisk actively thriving in the hobbyist
scene, it is also making beachheads into the Enterprise realm. A university in Texas recently replaced their
1600-phone strong mix of Nortel PBXes and Cisco Call Manager installations with Asterisk.The reasons
 for this were both the cost of licensing each phone to Cisco, and security concerns due to the fact they ran
on Windows 2000. A town in Connecticut recently deployed a 1500-phone Asterisk system, where each
department customized it for its own needs, such as the school department’s automated cancellation
notification system. Not only is Asterisk making it easy for companies to replace their existing telephone
systems, it is making it easy for telephone companies to have the ability to handle VoIP. Numerous
Competitive Local Exchange Carriers (CLECs) are jumping onto the VoIP bandwagon and setting it up to
handle VoIP from the consumer side (or handle it internally) for either a value-added service or a
cost-saving measure.

Asterisk as a New Dimension for Your Applications

The Internet has grown by leaps and bounds over the past ten years. Most companies have mission-critical
applications, applications to monitor the applications, and applications to monitor the applications that
monitor the applications, ad nauseam.There are also information systems designed to provide important
information to the general public.These systems all have something in common: they require the use of a
computer. Computers, while common, aren’t used by everyone. People constantly talk about the “digital
divide,” referring to people who are unable to afford computers. Plus, sizable portions of the populations,
for one reason or another, still treat the computer with apprehension. Phones, however, are very much
ubiquitous. Almost every home has a land-based telephone in it, and with pre-paid mobile phones finally
showing up in the United States, mobile phones are further penetrating the market. Despite this large market,
developing voice-aware applications has always been costly and time-consuming, making them less
common and less functional than their Web-based counterparts. Asterisk can be a bridge between the world
 of text and the world of speech. Thanks to programs like Sphinx (a program that translates speech to text),
Festival (a program that translates text to speech), and Asterisk’s own application interface, programs can
be written by any competent programmer. Asterisk’s interface is simple to learn yet extremely powerful,
allowing programs for it to be written in almost any language. Asterisk can be the conduit for taking your
applications out of the text that is the Internet and letting them cross over into the voice arena that is the
Public Switched Telephone Network (PSTN) A great example of how telephone-aware systems can
benefit the general public is Carnegie Mellon University’s “Lets Go!” bus dialog system. It has been
developed to provide an interactive telephone program that allows people in Pittsburgh to check the
schedule of buses that run in the city.The system has become such a success that the bus company has had
its main phone number forward calls to the application during off-hours, allowing callers to access
transportation schedules despite the office being closed. Asterisk can also be used to build similar systems
with the same tools used by CMU.

The Possibilities of VoIP

Looking at various trade magazines and Web sites, it is easy to get the feeling that pundits always rant and
rave about VoIP, but companies and end users either have no interest in it or do have an interest but no idea
what to do with it. Asterisk and VoIP provide many possibilities for both the end user sitting at home and
the company looking to cut costs.

Virtual Call Centers and Offices
Before VoIP, when running a call center, the company either needed to pay for a large building to house all
the employees, or pay the cost of forwarding the incoming phone calls to the employee’s houses.With the
advent of VoIP, a third option has emerged: using the employee’s broadband connections to handle
telephone calls over VoIP. Thanks to Asterisk, it is possible to run a call center out of a back pocket.The
only physical presences the call center needs are servers to handle the routing of the calls, and some way to
terminate the incoming phone calls, such as a VoIP provider or PRI(s).The people answering the calls can
either use their computer with a softphone and a headset, or some kind of Analog Telephone Adapter to
hook up a VoIP connection to a physical phone (more on these later). Agents can then sign into the call
queue without tying up their phone line or costing them money.They can also work anywhere a broadband
connection is available. This benefit isn’t limited to call centers either.Would you like to save some money on
your road warrior’s cell phone bills? Or, would you like to have an option for your employees to work from
home for a few days a week, but still have the ability to be contacted by phone like they were in their office?
The same concept applies. Once a phone signs into Asterisk, it doesn’t matter if it’s in the office, down the
street, or half a continent away, it becomes an extension on your PBX, with all the features and benefits.

Bypassing the Telephone Companies
Another way people have been using Asterisk is to set up their own “VoIP only” telephone network over
the Internet. Suppose you have a group of friends you never talk to.With Asterisk, you can essentially set up
your own virtual telephone company. After setting up Asterisk and then arranging the connections between
your servers, you can establish a telephone network without even touching the PSTN. Plus, thanks to
MeetMe, you can conduct conference calls with ease. Also, while the media and most of the public
associate “VoIP” with “phone calls over the Internet” this is only partly the truth.The “IP” in VoIP means
“Internet Protocol,” and Internet Protocol is Internet Protocol no matter where it is. If your company has
data links between buildings, campuses, or regions, but not voice links, Asterisk can be used to send voice
conversations over your data links as opposed to the phone lines, saving money and allowing your phone
lines to remain free for other purposes. One of the best hobbyist roll-your-own examples we’ve seen to
highlight Asterisk’s ability to act as an inexpensive gateway for telephones over large geographic areas is the
Collector’s Net at http://www.ckts.info. Founded in 2004, the Collector’s Net is a group of telephony buffs
who have, over time, collected old telephone switching equipment. For years, this equipment sat in
basements and garages collecting dust until one owner had the bright idea of using Asterisk and VoIP to
interconnect the gear over the Internet. And so Collector’s Net was born. It is growing monthly and now
boasts an Asterisk backbone connecting more than a dozen switches over two continents.
While it may seem trivial or downright odd to some, this highlights the ability of Asterisk to provide a
connection between a group of people who would have hardly spoken to each other had they not set up this
network.

Being Your Own Telephone Company
Asterisk can save money, but it can make money as well. It’s also simpler than you think. NuFone, one of
the first PSTN termination providers that supported Asterisk’s Inter-Asterisk eXchange (IAX) VoIP
protocol, started as a computer and a Primary Rate Interface (PRI), sitting in the owner’s apartment. It’s
now one of the more popular PSTN termination providers on the Internet. However, don’t start wearing
your monocle and lighting cigars with $20 bills just yet. In years past, termination providers were largely
flying under the radar of the various regulatory agencies. However, this golden age is rapidly coming to a
close, and VoIP providers are slowly becoming more and more regulated.Today,VoIP providers must
provide 911 services, are required to contribute to the Federal government’s “Universal Service Fund,”
must handle taps by law enforcement agencies, and are subject to all kinds of regulations.

Features and Uses

As previously stated, Asterisk has numerous features, some common to almost all PBXes, and some only
found in very high-end models. Let’s highlight a few.This is by no means a complete list, but just a sampling
of the many features Asterisk has to offer.

Conference Calls
Asterisk’s conference calling system, called “MeetMe,” is a full-featured conferencing system. All the
features you would expect in a conferencing system are included, such as protecting conferences with PINs
so only approved users can attend, moderating conferences to allow only certain people to speak to the
group, recording conferences so you can have a record of it, and playing music before a conference begins
so users don’t have to wait in silence.
MeetMe is a huge feature for Asterisk, as the price of commercial conferencing services isn’t cheap. Let’s
look at a simple example:We want to conduct an hour-long conference call with ten members of the press
concerning our new Asterisk book.A certain reputable conferencing service costs 18 cents per minute per
participant. So, doing the math, 13 users talking for 60 minutes at a cost of 18 cents/minute would cost us
$140.40. Let’s compare that with Asterisk. Using Asterisk, MeetMe, and an average VoIP toll-free
provider whose rates are 2.9 cents per minute per call, the same conference would cost us $22.62.That’s a
savings of $117.78!

Voice Mail
Voice mail has become critical to business in today’s market. Many people have developed a reflexive
tendency to check the “Message Waiting” indicator on their phone when first entering their
workspace.Technically, voice mail is quite simple. It is simply audio files stored on some kind of storage
medium, such as a hard drive or flash storage, on your PBX. Some vendors think a two-hour voice-mail
storage card, otherwise known as a 128MB Smart Media card, should cost over $200. Asterisk,
considering it’s run on a PC, affords you an amazing amount of storage space for your company’s voice
mail. Since it’s not locked into a specific storage media, you can add an extra hard drive, flash card, or
network share if you have the need to expand. Asterisk’s voice mail also incorporates almost every feature
one would expect from a voice-mail system: a complete voice-mail directory, forwarding, and the ability to
play different outgoing messages depending on whether the user doesn’t pick up their phone, is already on
the phone, or is out for a long period of time. Some of the more advanced features include the ability to send
the voice mail as an attachment to an e-mail address.This is useful if you are on the road and do not have a
phone available to you, but do have access to e-mail. It’s also very handy when you have a voice-mail
account you do not monitor regularly

Call Queues
While everyone might not know what a call queue is, almost everyone has experienced one. When dealing
with some kind of customer service department, it’s not uncommon to wait on hold while a disembodied
voice tells you that all the representatives are currently helping other people.That is a call queue.
It is used for handling large volumes of calls with a set amount of people answering the phones. When the
amount of calls (“callers”) exceeds the amount of people answering the phones (“answerers”), a queue
forms, lining up the callers till an answerer can attend to each. When one of the answerers becomes
available, the first caller in line gets routed to that answerer’s phone. Call queues are essential in any kind of
call center environment. Asterisk supports both queues in the traditional sense of a call center full of people,
and also a virtual call center in which the call agents call in from home and sit on the phone in their house. It
supports ringing all agents at once, a round-robin system, or a completely random ring pattern. Asterisk also
can assign priorities to callers when they enter a queue.

Asterisk as a VoIP Gateway
Asterisk’s biggest and most talked about feature is its VoIP capabilities.Thanks to the expansion of
Broadband into almost every company and an ever-increasing number of residences,VoIP has taken off in
the past few years. Asterisk has turned out to be a tool no one really knew they needed, but realized what
they were missing once they started using it.


People have started using Asterisk to augment, and sometimes even replace, their existing telephone
setup.Thanks to Asterisk

What Can Asterisk Do for Me?

Asterisk is so multifaceted it’s hard to come up with a general catchall answer for everyone asking what 
Asterisk can do for them. When a friend and I tried to think up an answer that would fit this requirement, the 
closest thing we could come up with was “Asterisk will do everything except your dishes, and there is a 
module for that currently in development.”

Asterisk as a Private Branch Exchange
Asterisk is, first and foremost, a PBX. Some people seem to constantly tout Asterisk’s VoIP capabilities,
and while that is a major feature, they seem to forget that Asterisk doesn’t need VoIP at all to be a PBX.
But even without VoIP, Asterisk has many advantages over traditional hardware-based PBXes.

Advantages over Traditional PBXes
Asterisk has numerous advantages over “traditional” PBXes.These advantages can benefit both larger and
smaller businesses. Let’s talk about two different scenarios, with two different problems, but one common
solution.
Asterisk in a Large Business Environment
Suppose you are the newly hired IT Director for a medium-sized office. While getting a tour of the server
room, you happen across the PBX. What you see disturbs you: a system, which handles approximately 200
people, is about the size of two mini fridges, requiring its own electrical circuit separate from the servers, and
producing enough heat it has to be tucked in a corner of the server room so as not to overload the air
conditioning system. It also seems to be stuck in the early 1990s:The system has abysmal voice-mail
restrictions, no call waiting, and no caller ID. Being the gogetter you are, you attempt to “buy” these features
from the vendor, but the quote you receive almost gives your purchase officer a heart attack. As if this
wasn’t enough, you also have a dedicated “PBX Administrator” who handles adding phones to the system,
setting up voice-mail boxes, making backups of the PBX, and nothing else. Asterisk is made for this kind of
situation. It can easily fit within a server environment, and will cut costs instantly since you no longer have to
cool and power a giant box that produces massive amounts of heat.Also, dedicated PBX administrators,
while possibly still necessary for a large environment, can be easily replaced by other, administrators,
provided they know how to administrate a Linux box. A competent Linux user can be taught how to
administer an Asterisk PBX easily. Finally, as stated repeatedly, Asterisk is open source, which really cuts
the software upgrade market off at the knees. Plus, if Asterisk lacks a feature a company needs, there are
more than a few options available to the firm: they can code it themselves, hire someone to code it for them,
or use Asterisk’s fairly active bounty system (available at http://www.voip-info.org).

Asterisk in a Small Business Environment
Asterisk provides advantages for small businesses as well. Suppose you are a consultant to a small company
that has you come in a few hours every week to fix computer problems.This company has a small,
ten-phone PBX that was installed by another vendor before you came into a picture. After a while, one of
the phones—the owner’s, of course—will no longer work with the voice-mail system. When you dial his
extension, it rings his phone, and then drops you to the main voice-mail prompt instead of going directly to
his voice-mail box. When he dials his voice mail from his phone, it prompts him for a mailbox rather than
taking him directly to his.The vendor no longer returns phone calls, and the owner begs you to take a look at
it. You bang your head against the wall for several hours trying to figure the system out. Besides the basic
“How to use your phone” info, no documentation is available, there are no Web sites discussing the system,
and diagnostic tools are non-existent. Even if you do figure out the problem, you have no idea how to
correct it since you don’t know how to reprogram it. In other words, you’re licked. Asterisk will fix most of
the issues in this situation as well. Documentation, while admittedly spotty for some of the more obscure
features, is widely available on the Internet. Asterisk debugging is very complete; it can be set up to show
even the most minute of details. Also, in a typical Asterisk installation, vendor tie-in wouldn’t be an issue. If
the owner’s phone was broken, a replacement phone could have been easily swapped in and set up to use
the PBX—no vendor needed


The History of Asterisk

Mark Spencer, the creator of Asterisk, has created numerous popular open-source tools including GAIM,
the open-source AOL Instant Messaging client that is arguably the most popular IM client for Linux, l2tpd,
the L2TP tunneling protocol daemon, and the Cheops Network User Interface, a network service manager. In 1999, Mark had a problem though. He wanted to buy a PBX for his company so they could have voice mail, call other offices without paying for the telephone call, and do all the other things one expects from a PBX system. However, upon researching his options, he realized all the commercial systems cost an arm and a leg.
Undaunted, he did what every good hacker would: he set to writing a PBX suitable to his needs. On
December 5, 1999, Asterisk 0.1.0 was released. As the versions progressed, more and more features were
added by developers, gathering a following of users, conventions, and everything short of groupies along the
way. Asterisk’s first major milestone was reached on September 23, 2004, when Mark Spencer released
Asterisk 1.0 at the first Astricon, the official Asterisk user and developer’s conference. Asterisk 1.0 was the
first stable, open-source,VoIP-capable PBX on the market. Boasting an impressive set of features at the
time, it included a complete voice conferencing system, voice mail, an impressive ability to interface into
analog equipment, and the ability to talk to three different VoIP protocols reliably. Development didn’t stop
there though. Asterisk continued to grow. On November 17, 2005, Asterisk 1.2 was released, which
addressed over 3000 code revisions, included major improvements to the core, more VoIP protocols, and
better scalability. Also, this release introduced Digium’s DUNDi (Distributed Universal Number Discovery)
protocol, a peer-to-peer number discovery system designed to simplify interconnecting Asterisk servers
across, and in between, enterprises.The latest release of Asterisk, Asterisk 1.4, was released December 27,  2006.This release featured major changes in the configuration process, optimized applications, simplified the
global configuration, and updated the Call Detail Records for billing purposes. Also new in this version was
better hardware support, an improved ability to interface with legacy equipment, and better interfacing with
Cisco’s SCCP VoIP protocol. Also, as with any software project, this update addressed the bugs and
issues found since the 1.2 release.

What is Asterisk , What Is a PBX, What is VOIP ?

Asterisk is an open-source PBX that has VoIP capabilities. However, this hardly explains what Asterisk is
or what it does. So let’s delve a little more deeply into PBXes,VoIP, and Asterisk.

Asterisk, first and foremost, is a Private Branch Exchange.A PBX is a piece of equipment that handles
telephone switching owned by a private business, rather than a telephone company. Initially in the United
States, PBXes were for medium-to-large businesses that would create a lot of telephone traffic starting from,
and terminating within, the same location. Rather than having that traffic tie up the switch that handles
telephones for the rest of the area, PBXes were designed to be small switches to handle this traffic.
The PBX would keep the internal traffic internal, and also handle telephone calls to and from the rest of the
telephone network.
PBXes are one of the key pieces of hardware in businesses today, ranging from small devices the size of
shoeboxes that handle a few lines to the telephone network and five phones in a small office, to a large
system that interconnects ten offices across a campus of buildings.
Asterisk is a complete PBX. It implements all the major features of most commercially available PBXes.

Voice over Internet Protocol is one of the new buzzwords of the media today. While VoIP has been around
in one incarnation or another since the 1970s, the market and technology has exploded over the past three
years. Companies have sprouted up selling VoIP services and VoIP software, and instant messaging services
are starting to include VoIP features.
But what exactly is VoIP? VoIP is a method to carry a two-way conversation over an Internet Protocol–
based network.The person using Vonage to talk to her neighbor down the street? That’s VoIP.The person in
the United States using Windows Messenger to talk to his extended family in Portugal? That’s VoIP.
The 13-year-old playing Splinter Cell on his Xbox and talking to his teammates about how they slaughtered the other team? That’s VoIP, too.
A normal call that uses the standard telephone network compression coder–decoder algorithm (codec), μ-
Law, will take up 64 kilobits per second of bandwidth. However, with efficient compression schemes, that
can be dropped dramatically