FOSSLC is a non-profit organization that specializes in technology and know-how to record conferences with excellent quality. Click on the icons below to view great videos from communities we are actively involved with:

 

Step by step - how to set up your own phone system using Asterisk

  • You are not authorized to post comments.
  • You are not authorized to post comments.
11 Aug in How To, Sysadmin, Asterisk
Asterisk

Asterisk How To

This how to guide describes how to set up Asterisk on Linux to enable phone calls between computers running voice over IP (VoIP) softphones, VoIP hardware, or regular telephones using VoIP adapters. As an added benefit, Asterisk provides rich features including voicemail, conference bridges, and more.

We hope you find this how to useful. If you did, please share it. If you have any feedback or suggestions, we'd love to hear them.

Read more to continue.

Why set up your own private branch exchange (PBX)

There may be many reasons you are interested in setting up your own phone system. Here are a few ideas that come to mind:

  1. Privacy
  2. Cost savings
  3. Benefit from new capabilities such as conference bridges or video phone
  4. Learn new technology

If this is your first time following these instructions, you may want to set aside 3-4 hours to complete all the steps. If your computer is fast at compiling, and you're familiar with the instructions, you may only need an hour.

Installation Instructions

I started by attempting to get all of this working using the default packages on Fedora. Fedora does not seem to include a few components such as voicemail that I wanted. After working on solving this, I've decided it's less time and effort to simply pull the source code and compile it rather than use the packages provided with Fedora. I personally believe it is always better to use the native package manager however in this case there was little choice. I also respect Fedora's right to not include non-free codec implementations.

Fortunately, pulling the code is quite easy. The following instructions should take you step by step through the installation. These instructions should work on most Linux distributions. For Ubuntu, you should be able to substitute "apt-get" for "yum" and have things work. When I get time I'll update this how to based on Ubuntu testing and any feedback.

Aside from any missing packages, there are three components to install: dahdi-linux, dahdi-tools, and asterisk.

a) Download, compile, and install dahdi-linux

You can find it here:
http://downloads.asterisk.org/pub/telephony/dahdi-linux/

Read the README file for instructions to compile. They are included here to provide an overview:

make

sudo make install

You'll need to ensure the modules load on boot:

On Fedora, add the following file:

/etc/sysconfig/modules/dahdi.modules

And the contents should be:

#!/bin/sh

# Add the asterisk dahdi_dummy module on boot
/sbin/modprobe dahdi_dummy

NOTE: Don't forget to "chmod 755 /etc/sysconfig/modules/dahdi.modules"

To add the modules right away without rebooting, you'll do the following:

modprobe dahdi
modprobe dahdi_dummy

NOTE: You may need to install the Linux kernel source in order to build if you do not already have it installed. To do this on Fedora, run the following as root:
yum install kernel-devel

b) Download, compile, and install dahdi-tools

You can get it here:
http://downloads.asterisk.org/pub/telephony/dahdi-tools/

Read the README file for compile instructions. They are typical for open source software.

./configure

make

sudo make install

c) Download and compile asterisk

You should get the most recent stable version from http://www.asterisk.org/

For example, in my case I grabbed the url to the tar file from the website and typed:
"wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.0.10.tar.gz" and hit enter.

You may need to install termcap libraries if you do not already have them installed. To do so:

yum install libtermcap-devel

To do the build, refer to the instructions in README. A summary of the commands is:

./configure

make menuselect

make

sudo make install

sudo make config

NOTE: you can use the target "sudo make samples" to create your initial configuration files. If you patch the code and rebuild, you likely won't want to do this as it'll clobber your current config files.

Configuration Instructions

This next section will show you how to configure your asterisk server to prepare it for VoIP clients.

Session Initiation Protocol

In order to establish voice or video calls, a protocol is required to establish connections and data streams. Session Initiation Protocol (SIP) is one such protocol that has grown in popularity. As a result it is widely supported by hardware, software, and servers including Asterisk. This how to will use SIP to establish VoIP calling. In the future we'll cover other protocols including IAX2 which has some technical advantages over SIP.

Key configuration files

Asterisk is a platform that provides infrastructure for many services including voice calls, video calls, voice mail, conferencing, and more. Out of the box, each of these "applications" are configured separately using a configuration file found in /etc/asterisk. The files we will modify for this example are:

sip.conf - used to configure sip lines

;To create line 1111 with a password of 1234, add the following to your sip.conf file.

;You can copy, paste, and update to create additional lines.  For example we'll also create 1112 so we can call each other.

[1111]
type=friend
secret=1234
qualify=yes    ; Qualify peer is not more than 2000 mS away
nat=no         ; This phone is not natted
host=dynamic   ; This device registers with us
canreinvite=no ; Asterisk by default tries to redirect
context=home

[1112]
type=friend
secret=1234
qualify=yes    ; Qualify peer is not more than 2000 mS away
nat=no         ; This phone is not natted
host=dynamic   ; This device registers with us
canreinvite=no ; Asterisk by default tries to redirect
context=home

extensions.conf - used to define a dial plan that teaches asterisk what to do when certain events such as calls happen

; We'll cover macros in more detail later. They allow substitution and some programming logic

; In this case, we'll get you to copy and paste the following into your extensions.conf file

; It provides the macro to create SIP lines with voicemail with one line. The lines are below the [macro-voicemail] stanza

[macro-voicemail]
exten => s,1,Dial(${ARG1},5)
exten => s,2,Goto(s-$DIALSTATUS},1)
exten => s-NOANSWER,1,voicemail(${MACRO_EXTEN})
exten => s-NOANSWER,2,Hangup()
exten => s-BUSY,1,voicemail(${MACRO_EXTEN})
exten => s-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-NOANSWER,1)

[home]
exten => 1111,1,Macro(voicemail,SIP/1111)
exten => 1112,1,Macro(voicemail,SIP/1112)

voicemail.conf - used to define voice mailboxes

;The following text added to your voicemail.conf file defines two voicemail boxes with password 1234.

; Once you log in, you can change the password

[default]
1111 => 1234,John Doe,john.doe@fosslc.org
1112 => 1234,Jane Doe,jane.doe@fosslc.org

meetme.conf - used to define conference bridges

; Usage is conf => confno[,pin][,adminpin]

; We'll define conference bridge 90 to be wide open and 91 to have both a user and admin password

conf => 90

conf => 91,1234,4321

Firewall update

You must make sure your firewall rules allow traffic to Asterisk. The default port is 5060. The default protocol is UDP. You can check it in sip.conf

e.g.

bindport=5060

To open UDP port 5060 and other necessary ports to your local private network, on a Fedora system, in, /etc/sysconfig/iptables, add:

-A INPUT -s 192.168.1.0/24 -d 0/0 -p UDP --destination-port 5060 -j ACCEPT

-A INPUT -s 192.168.1.0/24 -d 0/0 -p UDP --dport 10000:20000 -j ACCEPT

(adjust the ip scheme accordingly to suit your network)

Enjoy

You should now have a working asterisk install. We'll cover starting, stopping, managing logs, and other useful operational things in Step by step: running and managing your phone system using asterisk.

You have a choice of software or hardware VoIP phones to choose from. We'll cover these as well soon.

Comments

Getting prerequisites

On a Fedora machine, save yourself time and effort by installing the following groups before trying to compile Asterisk:yum groupinstall "Development Libraries" "Development Tools"

Great post

Thanks for this awesome post. I was looking for this kind of information. Please continue writing....Regards

Thanks for this highly

Thanks for this highly detailed guide on installing and using Asterisk. It helped me finally set up my two Voip Telephones after I had almost given up on the matter since the installation guides were written in japanese :)

Hey Arrros. Greetings from a

Hey Arrros. Greetings from a newbie :)that's a very useful and detailed tutorial I've been searching for. I look forward to other  tutorial of other voip phones. Thanks again.Regards,Mike.

phone systems

To find and compare
quotes from different Phone Systems providers, come visit us at Resource Nation  

Good post but ...

... obviously this is aimed at those that have the time and resources to install. With <a href="http://www.powwownow.co.uk">free phone conference</a> providers available i'm not sure if I would get myself involved in installing a system such as this.

Powerful Small Business Phone System Technology

Using phone systems are really of big help not only for individual needs but for businesses as well there are numerous providers who offer quality products at cost effective prices. For more options, please visit:
http://www.neobits.com
Phone System

Overview of asterisk with wireless

The following is a good overview of wireless technologies you can use with asterisk.http://www.packtpub.com/integrating-asterisk-with-wireless-technologies-part-1

asterisk with wireless

thanks for this link, I just got the 

Asterisk 1.4 – the Professional’s Guide from here

although I needed It was a bit pricey, thank you  regards Vero

Asterisk: the future of telephony

This O'Reilly book is available on Google books. Check it out!
http://tinyurl.com/asterisk-book