Build Your Own PBX With Asterisk and Linux

Enterprise Networking Planet content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Building your own corporate phone system using the Asterisk open source telephony suite could result in massive cost savings for your company, but it’s not for the faint-hearted: Asterisk is a complex system, and if you mess up the phone system it could end up costing you your job.

Personally I’d recommend taking an Asterisk Fast Start course to get you up and running, but if you fancy trying out Asterisk in the lab to see if it might be suitable for your organization here’s what you need to know to start.

Firstly you’ll need a Linux box to install Asterisk onto – the one I have is running Ubuntu Jaunty, but you can run Asterisk on pretty much any Linux distro with a kernel version 2.6 or later.

You’ll also need the GCC version 3.x or later for compiling, and the following system libraries and applications:

  • openSSL and its development libraries

  • ncurses and ncurses-devel (for the CLI)

  • zlib (compression library)

  • newt and newt-devel libraries (for DAHDI utilities)

  • curl (to allow Asterisk to interact with web sites)

  • sendmail or postfix (for sending voicemail to your email)

Once you have a suitable rig set up, head over to and download four tarballs, for Asterisk (the asterisk code itself), libpri (which handles ISDN telephony), dahdi-linux (a package formerly known as zaptel, which handles analog and digital telephony interfaces), and dahdi-tools, which has some dahdi-related utilities.

It’s a good idea at this stage to copy them to /usr/src/.

Now open a terminal window, and cd to /usr/src/

A quick ls -l in that directory will list the versions of the tarballs you have, which will probably be something like:


Don’t worry if the versions aren’t exactly the same as the ones above. Now, with root privileges, extract the tarballs, using

# tar –zxvf libpri-1.4.10.tar.gz
# tar –zxvf dahdi-linux-2.2.0.tar.gz
# tar –zxvf dahdi-tools-2.0.0.tar.gz
# tar –zxvf asterisk-

Again, do an ls –l to ensure you have four directories in /usr/src/ :


Continued on Page Two: Building the Source and Installing Asterisk

The next step is to compile the source code, starting with libpri, followed by DAHDI and DAHDI tools, and finally Asterisk itself.

To compile libpri, go to the command line and type:

# cd libpri-1.4.10
# make clean
# make install
# cd ..

Then compile DAHDI:

# cd dahdi-linux-2.2
# make all
#make install
#cd ..

When this is complete, compile and install DAHDI tools:

# cd dahdi-tools-2.0.0
# ./configure
# make
# make install
# make config
# cd ..

Finally, it’s time to compile Asterisk.

# cd asterisk-
# make menuselect

This will bring up a text-based menu offering various modules that you can select to compile, as well as various other options. To prevent unnecessary error message while learning to use Asterisk, deselect pbx_ael . Save the changes by pressing x, then continue to:

# make
#make install
#make samples (to install sample config files which are useful when learning to configure Asterisk)
# make config

Finally, reboot the system.

When the system comes back up, Asterisk should start automatically. To check that everything is working, check DAHDI is loaded by opening a terminal window and, with root privileges, typing:

# lsmod | grep dahdi

You should see references to several dahdi modules, including dahdi_dummy, dahdi_transcode, crc_ccitt, and dahdi_voicebus.

Check Asterisk is running and log on to the Asterisk command line with:

#asterisk –r

You should see some version and license information along with a “Connected to Asterisk” message and prompt.

To stop asterisk from the Asterisk command line type

CLI> stop now

or from the Linux command prompt type

# service asterisk stop


Configuring an Asterisk system and getting it fully working is beyond the scope of this piece, but here are some pointers to get started.

When using Asterisk, calls are treated as having two parts: a call in to the Asterisk box, and another call out to its destination. Pairing these two calls so that you end up talking to the person you want to is handled by Asterisk’s configuration files, which are mostly to be found in the /etc/asterisk/ directory.

To configure the system to handle calls to and from SIP devices (either physical SIP phones or software-based SIP softphones), the SIP devices first have to be registered in the relevant configuration file, which, logically enough, is called sip.conf. You can edit Asterisk’s many .conf files using any text editor, such as nano or gedit

You’ll also have to edit the extensions.conf file to assign an extension number to that device. This tells Asterisk that when it receives a call for extension 6001, for example, it should make an outward call to connect to the appropriate phone. You can optionally add other behaviors, such as that a different phone extension, or perhaps the mailbox system, should be called if the first phone is not answered within a given period of time.

Confused? It’s inevitable really: it takes a while to get your head round the basics – which have barely been touched upon in this article – but if you persevere it all begins to make perfect sense surprisingly quickly.

If you want to learn more about how to configure your running Asterisk installation to make and receive calls, you’ll need to buy a book like Asterisk The Future of Telephony published by 0’Reilly, find an online tutorial, or – as mentioned earlier – go on a three day Asterisk Fast Start course.

Don’t expect to master Asterisk quickly, but also don’t forget that if you succeed you’ll be in a very good position to make some significant savings for your company.

Paul Rubens
Paul Rubens
Paul Rubens is a technology journalist specializing in enterprise networking, security, storage, and virtualization. He has worked for international publications including The Financial Times, BBC, and The Economist, and is now based near Oxford, U.K. When not writing about technology Paul can usually be found playing or restoring pinball machines.

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends, and analysis.

Latest Articles

Follow Us On Social Media

Explore More