Vo
IP S
tud
y an
d Im
ple
men
tati
on
VoIP – Study and Implementation Labs
Objectives
Implementing a complete VoIP solution using Asterisk
Version 0.9b
Last update: 24/02/2011 Use: internal
Authors: M. PYBOURDIN - C. BORCKE
VoIP Study and Implementation Labs
Index
1. ABOUT THIS DOCUMENT ...........................................................................................................................................3
2. CASE PRESENTATION .................................................................................................................................................4
3. IMPLEMENTING THE SOLUTION .................................................................................................................................5
3.1. STEP 1.1 – PREPARING THE VIRTUAL MACHINE ..................................................................................................................... 5 3.2. STEP 1.2 – DAHDI INSTALLATION ...................................................................................................................................... 5 3.3. STEP 1.3: DAHDI CONFIGURATION .................................................................................................................................... 6 3.4. STEP 1.4 – LIBPRI COMPILATION......................................................................................................................................... 6 3.5. STEP 1.5 – ASTERISK COMPILATION .................................................................................................................................... 7 3.6. STEP 1.6 – CREATING A SIMPLE DIALPLAN ........................................................................................................................... 7 3.7. STEP 1.7 – IMPLEMENTING THE TOULOUSE IPBX .................................................................................................................. 8 3.8. STEP 1.8 – TESTING THE SOLUTION..................................................................................................................................... 9
4. ADVANCED CONFIGURATION .................................................................................................................................. 10
4.1. STEP 2.1 – AUDIO CONFERENCE....................................................................................................................................... 10 4.2. STEP 2.2 - VOICEMAIL.................................................................................................................................................... 10 4.3. STEP 2.3 – SPEAKING CLOCK ........................................................................................................................................... 12 4.4. STEP 2.4 - INTERACTIVE MENU......................................................................................................................................... 12 4.5. STEP 2.5 – CALL FORWARD ............................................................................................................................................. 13 4.6. STEP 2.6 – QOS CONFIGURATION .................................................................................................................................... 14 4.7. STEP 2.7 - LOGGING ...................................................................................................................................................... 14 4.8. STEP 2.8 - AUTOMATION................................................................................................................................................ 15 4.9. STEP 2.9 – TIME TO GO ONLINE ....................................................................................................................................... 15 4.10. STEP 2.10 – UNIFIED COMMUNICATION .......................................................................................................................... 17 4.11. STEP 2.11 - MONITORING ............................................................................................................................................ 18
Page 2 / 19
VoIP Study and Implementation Labs
1. About this document
This document contains the two activities for the SUPINFO VoIP Course taught to the M1 Students.
The scenario of this course is as below :
Core Knowledge – VoIP Ecosystem and Strategy (2 hours)
Core Knowledge – Asterisk Overview (2 hours)
Labs – Part 1 – Implementing an Asterisk Solution (6 hours)
Core Knowledge – Quality of Service (2 hours)
Labs – Part 2 – Advanced configuration (8 hours)
Those labs are built upon a case study which aims at being as close as possible as professional context.
Document versioning:
0.9a: Initial version 0.9b: Minor correction
Page 3 / 19
VoIP Study and Implementation Labs
2. Case presentation
You work as an IT Manager for a 9 employees service company.
This company has several office including : - An office in Toulouse, France - Its main office in Paris, France
Those sites are linked thanks to a Site-To-Site VPN provided through a DSL line with QoS enabled.
Many users complained about the company phone services. Indeed, the actual solution is made with a old PABX installed in the 90’s with very limited features :
Only the boss of the company has a direct line
No answering machine features
Users cannot put a call on hold
Users have to user their own solutions for conferencing
Also, your IT Budget is impacted by the cost of the phone services and the maintenance contract from the PABX provider.
To improve the infrastructure, you boss ask you to conduct a study on the PABX migration to a « Full-IP » solution. Of course, this solution must have a cheap infrastructure cost and be as flexible as possible.
Your company owns 10 phone number from 0140700500 to 0140700509
First you ask your intern to conduct a study on the users request. Here is below his feedback:
- Employees need to be directly reachable from the outside. - Existing numbers must be transferred from the previous operator - Employees need to have their personal voicemail box. - Sites being separated, employees must be able to call themselves and be able to forward incoming calls. - A main number must redirect to the boss assistant phone - Call must be able to be placed on hold - An audio conference solution must be implemented. - Calls must be made from phones but also from Mac OS X or Microsoft Windows Computers.
You decide to sort all the needs in three categories according to their importance:
Page 4 / 19
VoIP Study and Implementation Labs
Feature Vital Important Minor
Employees need to be directly reachable from the outside. X
Existing numbers must be transfered from the previous operator X
Employees need to have their personal voicemail box. X
Sites being separed, employees must be able to call themselves and be
able to forward incoming calls. X
A main number must redirect to the boss assistant phone X
Call must be able to be placed on hold X
An audio conference solution must be implemented. X
Calls must be made from phones but also from Mac OS X or MS
Windows Computers. X
Technical considerations
During your search for a technical solution, you discover the Asterisk solution which is a open source and free software transforming your Linux server (Gentoo, CentOS, Debian, …) in a full VoIP server ! Since its features meet your requirements, you decide to prepare a demonstration of the solution for the company on a virtual Machine.
In order not to saturate your DSL line, you decide to set on IPBX per office and link them with the IAX protocol.
3. Implementing the solution
3.1. Step 1.1 – Preparing the virtual Machine
First you need download the virtual machine and to check that your physical computer can dialog with it.
Download the virtual machine located on ftp-ssc.supinfo.com and configure it so the network adapter is set to “Bridged” and that the virtual machine IP is set to dynamic.
Note : - All the resources for this workshop are available on the virtual machine in /usr/src. - login/passwords of the machine :
root/Supinf0 supinfo/P@ssw0rd
We’ll start by implementing the IPBX which will be located in Paris.
3.2. Step 1.2 – DAHDI installation
Why do we have to install DAHDI on our system ?
We have to install DAHDI on our system because we need to provide to Asterisk the interface that allow communication between hardware telephony cards and the
software(here Asterisk). Is it also mandatory for MeetMe conferences and IAX trunking.
Page 5 / 19
VoIP Study and Implementation Labs
Indicate the different steps to install DAHDI on your system : cd /usr/src/dahdi-linux-complete-2.4.0+2.4.0/ make all make install
make config
3.3. Step 1.3: DAHDI configuration
Indicate the different steps to configure DAHDI on your system :
cd /etc/dahdi ls -l # Explore files in this directory and watch the comments to understand the purpose
of each file.
3.4. Step 1.4 – libpri compilation
What is the libpri used for ?
Libpri is mandatory for Asterisk, even if you don’t use PRI telephony cards. Without the libpri, you won’t be able to compile Asterisk.
Indicate the different steps to compile the libpri on your system : cd /usr/src/libpri-1.4.11.5/ make all
make install
Page 6 / 19
VoIP Study and Implementation Labs
3.5. Step 1.5 – Asterisk compilation
Indicate the different steps to compile Asterisk and Asterisk modules on your system :
cd /usr/src/asterisk-1.8.3-rc3 ./configure
make make install make samples
Your IPBX is now install and ready to go ! Now, let’s start the configuration in order to meet the employees requests.
3.6. Step 1.6 – Creating a simple DialPlan
Modify the general context so :
- You will just allow the ulaw codec for the communications - The Asterisk server will listen on all the interfaces on the port 5060 - The default context is « internal_calls » - The DMTF code is the one from the rfc2833 RFC - Overlap dialing is not allowed
Which file has to be modified ?
/etc/asterisk/sip.conf
Which are the modifications to do ? In the [general] section: context=internal_calls
port=5060
disallow = all allow = ulaw
dtmfmode = rfc2833 allowoverlap=no
Create two extensions with the following parameters :
Username: 500 Password : 1234 The extension is not NATed The extension can be qualified by default (60 seconds) The host has a dynamic address The RTP flow is redirected from the caller to the receiver
Username: 501 Password : 4321
Page 7 / 19
VoIP Study and Implementation Labs
The extension is not NATed The extension can be qualified by default (60 seconds) The host has a dynamic address The RTP flow is redirected from the caller to the receiver
Create a context for internal calls with the following parameters:
- Name of the context : « internal_calls » - A call to the 500 extension make the 500 extension ring - A call to the 501 extension make the 501 extension ring - After 20 seconds, the call is considered as failed.
Indicated the modifications you have to do to meet those requirements:
Dans /etc/asterisk/users.conf : [500] type=friend secret=1234
nat=no qualify=yes host=dynamic
context=internal_calls canreinvite=yes
[501] type=friend secret=4321
nat=no qualify=yes host=dynamic
context=internal_calls canreinvite=yes Dans /etc/asterisk/extensions.conf : [internal_calls]
exten => 500,1,Dial(SIP/500,20) exten => 500,2,Hangup()
exten => 501,1,Dial(SIP/501,20) exten => 501,2,Hangup()
exten => _5XX,1,Dial(SIP/${EXTEN},20) exten => _5XX,2,Hangup()
3.7. Step 1.7 – Implementing the Toulouse IPBX
Note : At this moment of the lab, you have two possibilites: Make a clone of the first machine Start a second virtual Machine on your computer or work in team with another student. If you decide to work alone, setting the network interfaces to NAT is a good option.
To prepare your demonstration, you prepare a second virtual Machine to act as the Toulouse site IPBX. The architecture of the network is considered as below :
Page 8 / 19
VoIP Study and Implementation Labs
Page 9 / 19
To interconnect your two, you decide to use the IAX protocol.
The extensions of the new site will start with the number 6.
Modify the dialplan to meet those requirements and set the two servers so Paris users and Toulouse users can call themselves.
What do you need to configure to do so ?
In both machines in iax.conf : [general]
autokill=yes register => USERNAME-LOCAL:1234@IP-MACHINE-DISTANTE
#Ici, username = paris ou toulouse [USERNAME-LOCAL]
type=peer host=dynamic trunk=yes
secret=1234 context=internal_calls qualify=yes
In sip-paris machine : extensions.conf : exten => _6XX,1,Dial(IAX2/USERNAME-LOCAL/${EXTEN}) In sip-toulouse machine : extensions.conf : exten => _5XX,1,Dial(IAX2/USERNAME-LOCAL/${EXTEN})
VoIP Study and Implementation Labs
Page 9 / 19
3.8. Step 1.8 – Testing the solution
On each physical machine, configure your favorite SIP Clients to connect if to one of the server and try to make a call.
VoIP Study and Implementation Labs
Page 10 / 19
4. Advanced configuration
Now that your demonstration with distributed IPBX installed on your virtual machines in functional, you decide to focus on the implementation of the different features that were requested.
Modifications must be applied on both IPBX.
4.1. Step 2.1 – Audio conference
The objective of this part is to set an audio conference room available from everyone by calling the number 900.
Which file has to be modified?
/etc/asterisk/meetme.conf /etc/asterisk/extensions.conf
Which are the modifications to do?
conf => 900 Dans extensions.conf: exten => 900,1,MeetMe(900)
What is the main difference between MeetMe and ConfBridge? Unlike MeetMe, ConfBridge does not perform audio mixing using DAHDI. Instead, audio mixing is performed within the internals of Asterisk.
Once configured, test this feature by calling the 900 from the 500 extension, then repeat the operation from the 501 extension.
4.2. Step 2.2 - Voicemail
The objective of this part is to create a voicemail service for each user.
The voicemail must be reachable with the number 777
VoIP Study and Implementation Labs
Page 11 / 19
The users will have to authenticate to their own voicemail box with a specific password.
If no one answer after 20 seconds, the call is redirected to the voice mail.
User Voicemail number Voicemail password Paris
500 500 5678
501 501 8765
Toulouse 600 600 1234 601 601 4321
Which files should be modified ?
/etc/asterisk/voicemail.conf /etc/asterisk/extensions.conf
Which are the modifications to do ? In voicemail.conf of sip-paris : [sip-paris] 500 => 5678,Voicemail 500 501 => 8765,Voicemail 501
In voicemail.conf of sip-toulouse : [sip-toulouse] 600 => 5678,Voicemail 600 601 => 8765,Voicemail 601
Now, voicemail are configured but we still have to configure the voicemail number (which can be done by modifying the dialplan).
Which file has to be modified ? /etc/asterisk/extensions.conf
Which are the modifications to do ? exten => 777,1,VoicemailMain(@sip-paris)
# or exten => 777,1,VoicemailMain(@sip-toulouse)
The final step is to configure the redirection after 20 seconds.
VoIP Study and Implementation Labs
Page 12 / 19
Which file has to be modified?
/etc/asterisk/extensions.conf
Which are the modifications to do ?
In extensions.conf of sip-paris : exten => 500,2,Voicemail(500@sip-paris) exten => 500,3,Hangup()
exten => 501,2,Voicemail(501@sip-paris) exten => 501,3,Hangup()
exten => 777,1,VoicemailMain(@sip-paris)
In extensions.conf of sip-toulouse : exten => 600,2,Voicemail(600@sip-toulouse) exten => 600,3,Hangup()
exten => 601,2,Voicemail(601@sip-toulouse) exten => 601,3,Hangup()
exten => 777,1,VoicemailMain(@sip-toulouse)
VoIP Study and Implementation Labs
Page 13 / 19
4.3. Step 2.3 – Speaking Clock
To impress the users with Asterisk feature, you decide to implement a speaking clock system. This speaking clock will be available by calling the 3669 number and will be set to your own timezone.
It will indicate the day of the week (Monday, Tuesday, …), the day in the month (1,2, …), the name of the month, the year and then the hour and minutes.
To do so, go to the /etc/asterisk/extensions.conf file and modify it to configure the speaking clock.
exten => 3669,1,Answer() exten => 3669,2,SayUnixTime(,Europe/Paris,AdbY HM) exten => 3669,3,Hangup()
Once configured, test the solution.
4.4. Step 2.4 - Interactive menu
Your boss comes into your office to see how the demonstration is evolving. He tells you that, considering the number of numbers to remember, he would like an interactive menu to guide to caller to the requested service.
You find that this feature is called an IVR and you decide to implement it in your solution.
The arrival message will be located in /var/lib/asterisk/sounds/en/hello-world.gsm
VoIP Study and Implementation Labs
1 redirects to the speaking clock
2 redirects to the conference room
3 redirects to the voice mail
Any other key redirects to the interactive menu
In the /etc/asterisk/extensions.conf file, add the lines to configure the interactive menu. exten => 888,1,Goto(ivr,s,1) [ivr]
exten => s,1,Answer exten => s,2,Playback(hello-world) exten => s,3,Set(TIMEOUT(digit)=5)
exten => s,4,Set(TIMEOUT(response)=10) exten => s,5,WaitExten
exten => 1,1,Goto(internal_calls,3669,1) exten => 2,1,Goto(internal_calls,900,1) exten => 3,1,Goto(internal_calls,777,1)
exten => _[04-9*#],1,Goto(ivr,s,1)
Once configured, test the solution calling the appropriate number.
4.5. Step 2.5 – Call forward
Now we have to implement call forwarding.
The conditional forward allows you to forward the call by announcing the forward to the recipient
The unconditional forward directly forward the call.
The « call parking » allows you to park the call temporarily, then to retake the call, which can be useful when you want to change of phone without knowing the one you will choose.
A forward to 700 list the parking number which will have to be between 701 and 710.
Indicate the steps to configure the call forward :
In /etc/asterisk/features.conf, uncomment in the section [featuremap]: blindxfer => #1 atxfer => *2
parkcall => #72 In general context in the same file, modify lines : parkext => 700 parkpos => 701-710
Page 13 / 19
VoIP Study and Implementation Labs
Once configured, test the « call parking » feature by calling the 500 extension from the 501, then initialize a forward by pressing the « # » key then 700. You will then hear the extension where the call is parked to.
4.6. Step 2.6 – QoS configuration
You decide to test the Qos configuration to be sure that the users will have the best quality of service the network can provide.
You discover that Asterisk can modify the TOS (Type of service) field of the IPv4 header for several protocols (IAX, SIP ...)
You decide then to configure Asterisk to modify those headers for the IAX and SIP protocols to use QoS.
Which file has to be modified? /etc/asterisk/sip.conf
Which are the modifications to do? Uncomment lines : tos_sip=cs3
tos_audio=ef tos_video=af41
To test your configuration, you can listen the traffic with tcpdump between the elements (Client to IPBX for the SIP protocol and IPBX to IPBX for the IAX).
4.7. Step 2.7 - Logging
After a talk with the accounting department, you boss comes to your office indicating that he needs to have a log of all the calls for each users in order to monitor them and to see if there are no abuse on personal calls during work time.
You decide to active and configure logging on the system. Those files will be in the /var/log/asterisk/cdr-csv/ folder.
Go to the /etc/asterisk/cdr.conf file and add logging to your solution.
Uncomment in [general] context: enable=yes
Once configured, test the solution by placing a call and check the logs.
tail -f /var/log/asterisk/cdr-csv/Master.csv to see change it in real-time.
Page 14 / 19
VoIP Study and Implementation Labs
4.8. Step 2.8 - Automation
As a regular geek, you had quite some fun in configuring thoses IPBX but you notice that the number of parameters to set for each new extension is huge and wastes a lot of time you do not have. Now that you know that this solution will be implemented in your company, you know you will not have the time on a daily basis to deal with the extensions management and dialplan administration.
You decide to implement a macro system with variables to same time and gain in productivity.
First, you modify the voicemail context so users will be identified with their extension calling number :
In /etc/asterisk/extensions.conf : exten => 777,1,VoicemailMain(${CALLERID(num)}@sip-paris) In /etc/asterisk/sip.conf : [suptemplate](!)
type=friend nat=no disallow=all
allow=ulaw context=internal_calls dtmfmode=rfc2833
In /etc/asterisk/users.conf :
[503](suptemplate) secret=1234
Once configured, test the solution.
4.9. Step 2.9 – Time to go online
Everything works inside the company now, but you now need to configure the connection to a SIP provider to be able to reach any phone in the world !
The authentication string to the provider will be:
user=user domain= myprovider.net secret=s3cret
Then you are going to create a section for the outgoing calls what will be used for any outgoing call from the company.
Note : If you have a SIP account from your ISP (Free for example), you can use it to test your configuration!
Page 15 / 19
VoIP Study and Implementation Labs
Modify the /etc/asterisk/sip.conf file to configure outgoing calls : register => user:[email protected] [external_trunk]
type=peer context=dial_out username=user
secret=s3cret disallow=all allow=ulaw
Create a context for outgoing call with the following parameters :
Name of the context : dial_out
Calls to the french fixed phones (01, 02, 03, 04, 05, 09 followed by 8 digits) are routed to the SIP gateway.
If the gateway is already in use, a message will tell the user that the gateway is busy and then the call will be hang- up.
[dial_out] exten => _0[1-59]XXXXXXXX,1,Dial(SIP/external_trunk/${EXTEN}) exten => 0[1-59]XXXXXXXX,2,Playback(tt-allbusy)
exten => _0[1-59]XXXXXXXX,3,Hangup()
Our futur VoIP provided displays the three last digits of each SDA. For each SDA we redirect the call according to the last 3 digits to a specific extension.
We are going to create a context named “Incoming Calls” that will be used to receive the calls from the SIP trunk with the following parameters:
Name of the context : « incoming_calls »
A call to the 0140700500 number (SDA 500) redirects to the 500 A call to the 0140700501 number (SDA 501) redirects to the 501
Note : A SDA is a direct selection that can be used to redirect external calls to a specific extension
Page 16 / 19
VoIP Study and Implementation Labs
[incoming_calls] exten => 0140700500,1,Dial(SIP/500)
exten => 0140700501,2,Dial(SIP/501)
4.10. Step 2.10 – Unified communication
Employees are thrilled by having soon this new phone system in the company; you received a lot of mails to thank you for your work on this demonstration.
One day, while you are reading your mail, you tell yourself : Wouldn’t it be great to link the Microsoft Exchange Server of the company to your Asterisk ?
Note : - login/password of the machine :
SOCIETY/Administrator / Supinf0
- login/password/PIN Number of the mail accounts : SOCIETY/jlocke / Supinf0 / 081987 SOCIETY/ctroy / Supinf0 / 081987
Outlook Auto-Attendant extension: 444 Outlook Voicemail extension: 777
Note: You can download the Microsoft Exchange Server Virtual machine from ftp-ssc.supinfo.com. Your Exchange UM server is already configured: you don’t have to modify it.
For this question you have to modify the hosts file of your IPBX to fit your configuration.
Modify the /etc/asterisk/sip.conf file to link to the Exchange Server :
[general] (…)
tcpenable=yes tcpbindaddr=0.0.0.0 promiscredir=yes (…)
[exchange_trunk] host=society-dc-1.society.lan; FQDN of your Ms Exchange UM role server. type=friend
Page 17 / 19
VoIP Study and Implementation Labs
qualify=yes canreinvite=no disallow=all allow=ulaw dtmfmode=auto insecure=very transport=tcp port=5065 context=intenal_calls
Then edit your /etc/asterisk/extensions.conf file as follow :
[to_exchange] exten => 444, 1, Dial(SIP/exchange_trunk/444) exten => 444, 2, Congestion()
[voicemail] exten => 777,1, Dial(SIP/exchange_trunk/777) exten => 777,2, Congestion()
[internal_calls] Include=>to_exchange
Finally you will modify the macros of internal calls in the /etc/asterisk/extensions.conf file as follow :
[macro-Internal_calls] exten => s,1,Answer() exten => s,2,Dial(${ARG1},20,Ttr) exten => s,3,SIPAddHeader(Diversion: <tel:${ARG1:4}>\;reason=no-answer\;screen=no\;privacy=off) exten => s,4,Dial(SIP/exchange_trunk/777) exten => s,5,Hangup()
4.11. Step 2.11 - Monitoring
Everything is working, users are thrilled, mission complete!
Now let’s focus on the maintenance of our IPBX :
Log files are store in /var/log/asterisk. The « message » file journalize all the warnings, the errors and the notices.
Test the following commands :
To connect to the Asterisk console :
sip:~# asterisk –r sip*CLI>
To visualize the registed SIP users on the server :
sip*CLI> iax2 show registry
To visualize the SIP extentions authenticated on the server : sip*CLI> sip show peers
Page 18 / 19
VoIP Study and Implementation Labs
To visualize IAX users : sip*CLI> iax2 show users
To see the state of the voicemail boxes :
sip*CLI> voicemail show users
To list the « meetme » conferences
sip*CLI> meetme list
To set a debut on a SIP extension : sip*CLI> sip set debug peer XXX
To raise the verbose level of the console
sip*CLI> core set verbose XX
To display current calls :
sip*CLI> core show calls
To display parked calls : sip*CLI> parkedcalls show
Page 19 / 19