SlideShare a Scribd company logo
E-Learning
Complete Deck of Slides of the
Complete Asterisk Training
You can enroll at:
http://bit.ly/2E6U7fP
E-Learning
Books, eBooks and Other Trainings
From the same Author
Online Trainings
Complete Asterisk Training Coupon http://bit.ly/2E6U7fP
Understanding and Troubleshooting SIP http://bit.ly/2WZKkzy
VoIP Design Training Coupon http://bit.ly/2tlLFmG
VoIP Hacking Training Coupon http://bit.ly/2GL5MCT
Quick Start to OpenSIPS Coupon http://bit.ly/2Bt72XJ
Books
Complete Asterisk Training Paperback and Kindle Book https://amzn.to/2tm7TFb
Complete Asterisk Training eBook PDF http://bit.ly/2UUebHG
Building Telephony Systems with OpenSIPS http://bit.ly/2SsUt9a
E-Learning
Welcome
Building a complete PBX
with Asterisk
E-Learning
• By the end of this training you should be able to:
– Understand what is Asterisk and where it can be applied
– Choose the appropriate hardware and software for your
project
– Install Asterisk
– Build a simple PBX with SIP phones and SIP trunks
– Call between phones to a SIP trunk and from a SIP trunk
– Configure an IVR and Auto-Attendant to receive calls
– Configure a Conference Room
– Configure a VoiceMail Server
– Understand how to integrate applications with Asterisk
Objectives of the training
E-Learning
• Most chapters have Labs
• You will need Virtual Box installed in your
notebook or laptop
• At the end of the training you should have a
simple system ready to run
Practical Training
E-Learning
Introduction to Asterisk
E-Learning
• By the end of this chapter you should be
able to:
– Describe what Asterisk is
– Understand the Asterisk ecosystem
– Select a hardware/software for your project
– Understand the Asterisk arquitecture
– Point common usage scenarios
– Find documentation and information
Objectives
E-Learning
What is it?
Asterisk is a PBX implemented as an open source software. It was
originally created by Mark Spencer in 1999. As any other PBX it
allows you to connect phones and make calls. With the passage of
time Asterisk has becoma a major telephony platform for applications
such as Dialers, Call Centers, Interactive Voice, Response,
SoftSwitches. The imagination is the limit.
E-Learning
E-Learning
E-Learning
E-Learning
Licensing
https://www.asterisk.org/products/software
E-Learning
Which hardware to use?
Phone
Company
IP Phones
Analog Telephone Adapters
ISDN and Analog Lines
SIP
Provider
Internet
Telephony
Service
Provider
Softphones
E-Learning
Which software to use?
E-Learning
Asterisk Versions
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
E-Learning
Asterisk Architecture
E-Learning
Asterisk Applications API
Asterisk Channels API
FileformatAPI
CodecTranslationAPIs
chan_dahdi (Analog and Digital
lines), chan_sip (SIP channels),
chan_iax (IAX channels)
Gsm,ALaw,Ulaw,G.723,G729,
ADPCM,MP3,Speex,LPC10
GSM,WAV,G723af,MP3
VoiceMail, Conference, Dial,
Background
Codec
Translator
Switching
Core
Application
Launcher
IO scheduler
and Manager
Dynamyc
Module
Loader
E-Learning
Channels
E-Learning
Codecs
G729 SLIN
SLING729
SLIN iLBC
SLIN iLBC
Codec Bandwidth Comment
G.711 ulaw 64 Kbps Excelent
G.711 alaw 64 Kbps Excelent
G.723.1 – Modo 5.3/6.3 Kbps Pass-thru only
G.726 32 Kbps Excelent
G.729 8 Kbps Excelent (Requires license)
GSM 13 Kbps Good Quality
iLBC 15-18 Kbps Good Quality
G.722 64 Kbps High Definition
Opus 5.3-512
Kbps
Narrowband to wideband
E-Learning
Protocols
• SIP;
• H323;
• IAXv1 e v2;
• MGCP;
• SCCP (Cisco Skinny);
• Nortel Unistim
E-Learning
File formats
E-Learning
Applications
cli>core show aplications
E-Learning
Use Scenarios
E-Learning
Lab. One Phone, One Line PBX
E-Learning
Enterprise Solutions
E-Learning
Connecting headquarters and
branches
E-Learning
Asterisk as an application
server
TELCO
E1/Analog
E1/Analog
Asterisk PBX
IVR
Conference
VoiceMail
E-Learning
Asterisk as a Contact Center
1-800
Agent1 Agent2 AgentN
DAC
Ringall,RoundRobin,Rrmemory,
LeastRecent,Priority
Call Queue
E-Learning
Asterisk vs. Conventional
system
IP Phones
Softswitch
PSTN Gateway
VoiceMail
Music On Hold
Analog Telephone
Adapter
CISCO IP PHONE
7905SERIES
1 2
A B C
3
D E F
4 5
J K L
6
M N OGH I
7 8
T U V
9
W X Y ZP Q R S
* 0 #
4
7
P QRS
*
CISCO IPPHONE
7905SERIE S
1 2
A B C
3
DE F
4 5
J KL
6
M N OG HI
7 8
TU V
9
W X YZP QR S
* 0 #
4
7
PQRS
*
CISCO IPPHONE
7905SERIE S
1 2
A B C
3
DE F
4 5
J KL
6
M N OG HI
7 8
TU V
9
W X YZP QR S
* 0 #
4
7
PQRS
*
Telco or PBX
Telco or PBX
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
IP Phones
Softswitch
Gateway for
Public
Networks
Unified
Messaging
System
Gateway for
Analog
Telephony
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
E-Learning
Where to find documentation
• wiki.asterisk.org
• www.asterisk.org
• www.voip-info.org
E-Learning
• AGI – Asterisk Gateway Interface
• AMI – Asterisk Managment Interface
• ARI – Asterisk Rest Interface
Integration with other systems
E-Learning
Summary
Arquitecture
Who?
Where?
When?
Why?
Usage scenarios
E-Learning
Downloading and Installing Asterisk
E-Learning
• By the end of this chapter you should be
able to:
– Dimension the required hardware
– Install
– Start and Stop
– Connect to the console
– Start Asterisk in the Linux boot
Objectives
E-Learning
• Labs, 1GB RAM, 10GB disk
• Virtual Box, Bridge Mode
• Ubuntu 16.04, 32 bits
Minimum hardware
E-Learning
• Empiric Process
• Use SIPP to test exceptions
• General Rules (80/20)
– 80% or more of the Asterisk users have less than 30
simultaneous calls and no more than 240 users. Any modern
server could take this load.
– If you belong to the other 20%, test using SIPP. Use a large
security coefficient. So if the test got 3000 simultaneous
calls, use a SC=4 and dimension for no more than 750.
Dimensioning
E-Learning
• Simultaneous calls
• Registered devices
• Transcoding
– Pay attention to high complexity codecs 1G729 = 13 MIPS, 1 narrowband
OPUS=30 Mflops.
• Call Attempts per second (CAPS)
– Load with more tha 100 CAPS can be problematic
Impairment factors
E-Learning
• CDRs in a database
– Each CDR generates I/Os for data and indexes
– SATA HD supports only 75 IOPS
• Recording. Recording is intensive in terms of
disk I/O
– Try to keep below 200 in a SAS 15K RPM disk
• Applications
– Conference Rooms, Queues and IVRs affect the
performance in an unpredictable way. It is not
possible to predict the performance of a unknow
application before it has been developed
Hardware notes
E-Learning
• Sipp – Traffic Generatos
• Sippy Cup -
http://mojolingo.github.io/sippy_cup/
Testing tools
E-Learning
• From te authors experience
– Use a good network switch and good interface
cards.
– Use Echo Cancelling by hardware (cards)
– Use a Transcoding card if you plan to transcode
a large amount of calls
Tips
E-Learning
Astricon 2017
• Tests on a low cost mini J1900 4GBRAM
E-Learning
Echo test with media
• Command line
• sipp -s 1000 10.8.1.46:5060 -sf sipp_pcap.xml
-i 10.8.1.46 -d 90000
E-Learning
Echo Test with media calls per
second
37
35
33
32 32
29
30
31
32
33
34
35
36
37
38
Asterisk 11 Asterisk 13 Asterisk 15
chan_sip chan_pjsip
E-Learning
Echo Test with media simultaneous
calls
3338
3076
2820
2700 2700
0
500
1000
1500
2000
2500
3000
3500
4000
Asterisk 11 Asterisk 13 Asterisk 15
chan_sip chan_pjsip
E-Learning
• Asterisk requires the following packages
– Asterisk
• Optionals
– dahdi-linux – drivers das placas
– dahdi-tools – utilitários para as placas
– libpri – usado para placas ISDN
Installation Packages
E-Learning
• From the source code
– Flexible
– Optmized
• From packages
– No official maintainers
– Usually not the latest version
– Simple and quick
• Distro
– FreePBX
– AsteriskNOW
How to install?
E-Learning
• The variety is huge
• Trend
– Use SIP trunking , forget cards
• If you don't have access to a SIP trunk
– Digium, Sangoma, OpenVOX, Aligera...
– Alternative cheap hardware (only If you have a hacker soul )
• CHAN_DONGLE https://github.com/bg111/asterisk-chan-dongle
• X100P (1 FXO)
Telephony Cards
E-Learning
Demo
E-Learning
• In this chapter you've learned how to
– Dimansion the hardware required for Asterisk
– Install Asterisk
– Start and Stop Linux
– Start Asterisk at the boot
– Connect to the console
Summary
E-Learning
Building an IP PBX Section Overview
E-Learning
• Part I – SIP extensions
• Part II – SIP trunks
• Part III – Dialplan
• Part IV – Adding features
Sections
E-Learning
By the end of this section you should be able to:
• Build a PBX with the following characteristics
– Support IP phones based on SIP
– Connect to a VoIP operator using a SIP trunk
– Dial between extensions
– Dial to external destination using 9 as a prefix
– Missed calls sent to the voicemail
– Conference room in the extension 5
– Incoming calls directed to an Operator or AutoAttendant
Objectives
E-Learning
Grammar Object Creation Conf. File Example
Simple group All in the same line extensions.conf exten=>4000,1,Dial(SIP/4000)
Inheritance Options defined before
object declaration
chan_dahdi.conf [channels]
context=default
signalling=fxs_ks
group=1
channel => 1
Complex entities Each entity receives a
context
sip.conf,
iax.conf
[cisco]
type=friend
secret=mysecret
host=10.1.30.50
context=from-internal
[xlite]
type=friend
secret=xlite
host=dynamic
Context=from-internal
Asterisk Grammar
E-Learning
LAB
E-Learning
Installation Sequence Overview
© 2009 Virtual Office Com. E Ind. Ltda. Todos os direitos reservados.
Estes slides fazem para do curso Asterisk Básico www.voffice.com.br/elearning
E-Learning
Building the PBX part I
Extensions
E-Learning
IP Phone Configuration
Analog Telephony Adapters
Softphones
ÌP Phones
E-Learning
sip.conf, General Section
[general]
bindport = 5060
bindaddr = 192.168.0.1
context = dummy
allowguest=no
alwaysauthreject=yes
disallow = all
allow = ulaw
seção geral do arquivo sip.conf
E-Learning
sip.conf, Devices section
[zoiper]
type=friend
secret=#m4rksp3nc3r#
host=dynamic
nat=yes
qualify=yes
directmedia=no
context=from-internal
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/255.255.0.0
[xlite]
…
E-Learning
LAB 3-1
Configuring the phones
E-Learning
Building the PBX part II
Trunks
E-Learning
• Becoming mainstream on Telcos
• Digital, high volume only limited to bandwidth
• No investment on legacy hardware
• Savings on rack space and eletricity
SIP trunks
E-Learning
• Providers's IP address
• Name and Password
• Some allow IP authentication
• Authentication per transaction
– Register
– Calls
• Return Address
– Which extension to ring when receiving an
incoming call
SIP trunk parameters
E-Learning
Asterisk Registration
register => login:passwd@domain:port/9999
Name
Password IP or domain
UDP port
Callback
Extension
E-Learning
• sip show registry
Checking the registration?
E-Learning
• RFC2833 – DTMF as named events
• INFO – SIP Info message
• Audio – DTMF as audio in the channel
DTMF
E-Learning
[general]
srvlookup=yes
register => login:pass@domain:port/9999
[siptrunk]
type=peer
defaultuser=login
secret=senha
port=5060
insecure=invite
host=dominio
fromuser=login
fromdomain=dominio
dtmfmode=rfc2833
context=from-sip
disallow=all
allow=ulaw
Creating a SIP trunk
E-Learning
Lab 3-2
Creating a SIP trunk
E-Learning
Building the PBX part III
Dialplan
E-Learning
• File /etc/asterisk/extensions.conf
• Extensions format
• Contexts, extensions and priorities
• Call flow between contexts
• Dialing between extensions
• Dialing external numbers
• Incoming calls
• Voicemail and conference rooms
Building a dialplan
E-Learning
Dialplan configuration
/etc/asterisk/extensions.conf
E-Learning
E-Learning
Call processing
[globlals]
OPERATOR=SIP/4000
[incoming]
exten=s,1,dial(${OPERATOR},20)
exten=s,n,hangup()
[default]
;dialing other extensions starting with 4
followed by three digits
exten=>_4XXX,1,Dial(SIP/${EXTEN},20)
exten=>_4XXX,n,hangup()
; Send every digit after 9 to the PSTN
exten=>_9.,1,Dial(ZAP/g1/${EXTEN:1},20)
exten=>_9.,n,hangup()
[4001]
type=friend
context=default
extensions.confchan_dahdi.conf
sip.conf
E-Learning
exten=>number(name),{priority|label{+|-}offset}[(alias)],aplication()
8000 Numeric
Alexander Alphanumeric
4321/ 1234 Numeric with CallerID
_4XXX Regular Expression
s Standard extensions
Extensions Format
Priorities Format
1-9 Priorit number
n next
s same
n+/-x n+x, n-x
s+/-x s+x, s-x
hint Presence related
Extensions Syntax
E-Learning
Simple example
exten=>123/100,1,Answer()
exten=>123/100,2,Playback(tt-weasels)
exten=>123/100,3,Hangup()
E-Learning
Pattern
Examples
_ (Underscore) Pattern start character
. (point) Wildcard one or more digits
! (exclamation) Wildcard one or more digits immediatey (ISDN)
[123-7] Any values in brackets (1,2,3a7)
X Any digit from 0-9
Z Any digit from 1-9
N Any digit from 2-9
E-Learning
Asterisk Standard Extensions
i : Invalid
s : Start
h : Hangup
t : Timeout
T : AbsoluteTimeout
o : Operator
a : used when “*” is pressed in the
voicemail menu
fax : used for fax detection
Talk : used for backgroundDetect()
Standard extensions
E-Learning
• Global
set(Global(variable)=content)
• Channel
${EXTEN} Called extension
${CONTEXT} Current context
${CALLERID} Current callerID
${PRIORITY} Current Priority
• Application
${DIALEDTIME}
${ANSWEREDTIME}
${DIALSTATUS}
CHANUNAVAIL
CONGESTION
NOANSWER
BUSY
Variables
E-Learning
Math operators
Add (+), Subtract (-), Multiply (*), Division (/), Modulus (%)
Logica operator
Logical “AND” (&), logical “OR” (|), denial (!)
Comparison operators
(=, >, >=, <,<=,!=)
Regular expression operators
Regular expression matching (:), Regular expression exact matching (=~)
Conditional operators
expression1 ? expression2 :: expression3
Expressions
Expressions
E-Learning
Operators, Functions and
Substrings
Example:
exten=>100,1,Set(Fruit=Orange)
exten=>100,2,NoOp(${LEN(Fruit)})
exten=>100,3,NoOp(${LEN(${Fruit})})
Eamples:
${string:offset:length}
${123456789:1}-returns 23456789
${123456789:-4}-returns 6789
${123456789:0:3}-returns 123
${123456789:2:3}-returns 345
${123456789:-4:3}-returns 678
Example;
$[${I}+100]
E-Learning
Applications
Applications to build a simple dial plan
 answer() – Answers a channel
 dial() – Dial another channel
 hangup() – Hangup a channel
 playback() – Play na audio file
 goto() – Jump to the next priority,
extension or context
E-Learning
The application Dial()
;Dialing a channel
Dial(type/identifier,timeout,options, URL)
;Dialing to multiple channels
Dial(Technology/resource[&Tech2/resource2...][|timeout][|opt
ions][|URL]):
exten=>_6XXX,1,Dial(SIP/${EXTEN},60,Tt)
E-Learning
Building a PBX, contexts
Context Description
from-siptrunk Calls coming from the siptrunk
from-internal All extensions SIP and IAX
E-Learning
Building the PBX
Dialing between extensions
[from-internal]
exten=>6000,1,dial(SIP/pap21A,20)
exten=>6001,1,dial(SIP/xlite1,20)
Dialing to the PSTN prefixing 9
[from-internal]
;Dialing to the PSTN via SIP trunk
exten=>_9.,1,dial(SIP/siptrunk/${EXTEN:1},20)
CLI>dialplan reload
E-Learning
Incoming Call from the SIP trunk
[globals]
OPERATOR=>SIP/6000
[from-siptrunk]
exten=>9999,1,dial(${OPERATOR},20)
Why 9999?
Remember:
register => login:pass@domain:port/9999
In the register command you define the
extension called for incoming calls
E-Learning
Lab 3-3
Building the PBX
E-Learning
Building the PBX part IV
IVR, Conference and Voicemail
E-Learning
• By the end of this chapter you will be able to:
– Record prompts directly from your phone
– Build an autoattendant
– Build a simple IVR
– Send missed calls to a voicemail
– Send calls to an audioconference room
Objectives
E-Learning
Recording Messages in a file
[from-internal]
exten => _4.,1,Record(${EXTEN:1}:gsm)
exten => _4.,n,wait(1)
exten => _4.,n,Playback(${EXTEN:1})
exten => _4.,n,Hangup()
Dialing 4100 will record 100.gsm
Dialing 4menu will record menu.gsm
Dialing 4greeting will record greeting.gsm
E-Learning
Auto-attendant
[from-siptrunk]
Include=autoattendant
[autoattendant]
exten=>9999,1,answer()
exten=>9999,2,background(greeting)
exten=>9999,3,Dial(${OPERATOR})
exten=>6000,1,Dial(SIP/xlite)
exten=>6001,1,Dial(SIP/zoiper)
Background(filename1[&filename2...][|options[|langoverride][|context]])
s – skip the message
n – Does not answer the channels before playing files (183 Early Media)
m – Stops when a digit matches the one digit extension in the destination context
E-Learning
Using an IVR
[from-siptrunk]
include=>ivr
[ivr]
exten=>9999,1,answer()
exten=>9999,n,background(greeting)
exten=>9999,n,Dial(${OPERATOR})
exten=>1,1,dial(SIP/zoiper)
exten=>2,1,dial(SIP/xlite)
exten=>3,1,dial(SIP/blink)
E-Learning
Voicemail and Conference
Voicemail general configuration (not necessary for users.conf)
[general]
[default]
<Mailbox ID> = <pincode>, <fullname>, <email address>, <pagermail>,
<option=value>, <option=value>
1234=>1234, Joe Doe, joedoe@somecompany.com, joedoe@somecompany.com,
saycid=yes
[stdexten]
exten=>s,1,Dial(${ARG1},20,tT)
exten=>s,n,Goto(${DIALSTATUS})
exten=>s,n,hangup()
exten=>s,n(BUSY),voicemail(${ARG2},b)
exten=>s,n,hangup()
exten=>s,n(NOANSWER),voicemail(${ARG2},u)
exten=>s,n,hangup()
exten=>s,n(CANCEL),hangup
exten=>s,n(CHANUNAVAIL),hangup
exten=>s,n(CONGESTION),hangup
[from-internal]
exten=>6000,1,Gosub(stdexten,s,1(SIP/6000,${EXTEN}))
exten=>6001,1,Gosub(stdexten,s,1(SIP/6001,${EXTEN}))
E-Learning
Voicemailmain()
exten=>9000,1,VoiceMailMain()
Level#1
0 Mailbox options
1 Read Voicemail messages
2 Change folders
* Help
# Exit
1 Record your unavailable message
2 Record your busy message
3 Record your name
4 Record your temporary message
5 Change your password
* return to the main menu
3 Advanced Options
4 Play previous message
5 Repeat current message
6 Play next message
7 Delete current message
8 Forward message to another mailbox
9 Save message in folder
0 inbox
1 old
2 work
3 family
4 friends
5 cust1
6 cust2
1 Accept
2 Review
3 Re-record
0 Reach
operator
1 Reply
2 Call Back
3 Envelope
4 Outgoing
call
VoiceMailMain()
Menus
E-Learning
Conference
ConfBridge
Conference bridge application.
[Description]
Enters the user into a specified conference bridge. The user can
exit the
conference by hangup or DTMF menu option.
This application sets the following channel variable upon
completion:
${CONFBRIDGE_RESULT}:
FAILED:The channel encountered an error and could not enter
the conference.
HANGUP:The channel exited the conference by hanging up.
KICKED:The channel was kicked from the conference.
ENDMARKED:The channel left the conference as a result of the
last marked
user leaving.
DTMF:The channel pressed a DTMF sequence to exit the
conference.
TIMEOUT:The channel reached its configured timeout.
[Syntax]
ConfBridge(conference[,bridge_profile[,user_profile[,menu]]])
exten=5,1,Confbridge(main)
E-Learning
Summary
Ending this section you are now able to:
• Understand and build configuration files
• Build a simple PBX
• Install and configure a SIP trunk
• Build a simple dial plan
• Dial between extensions and external destinations
• Receive calls in the operator
• Build a simple autoattendant system
E-Learning
Lab 3-4
Adding features
E-Learning
PBX Features
Overview
E-Learning
Objectives
• By the end of this chapter you should be able
to use:
– Call Transfer
– Call Pickup
– Three-way conference
– Call Parking
– Call Recording
– Music On Hold
– Follow me
E-Learning
Asterisk
Music on hold
Call transfer
Call parking
Call pickup
Call recording
Dialplan
Follow-me
Blacklist
In the phone
Call hold
Call transfer
Three-way conference
Message waiting indicator
Where resources are implemented
E-Learning
Call Transfer
Blind transfer
 You need to enable in the dial() applicationwith the
options “tT”;
 Press “#” during the call;
 Dial the extension to transfer to
 Hangup the call
 If the call does not go thru, it will ring back
Attended Transfer
 Enabled on features.conf (disabled by default);
 Dial “*2” to start the transfer;
 Dial the destination extension
 Talk to the person on the destination
 Hangup the call
 The system transfers the call
E-Learning
Call Parking
701 702 703 704
705 706 707 708
709 710 711 712
713 714 715 716
717 718 719 720
700
Parking Lot
1. Transfer the call to the
extension 700.
2. The call is parked in the
first free slot. The slot is
announced to you.
3. Call the extension
where the call was parked
and you resume the call.
E-Learning
Call Pickup
callgroup=1
pickupgroup=1
callgroup=2
pickupgroup=2
callgroup=3
pickupgroup=1,2,3
(Operator)
Operator capture
calls from
groups 1,2 and 3
Members
capture calls
only inside their
group
Sales P&D
E-Learning
Call Recording
• Call MixMonitor before the Dial command.
• In line recording – automixmon
– Don't forget the X option in the Dial() command
MixMonitor(<file>.<ext>[|<options>[|<command>]])
Records The audio on the current channel to the specified
file.
Valid Options:
b – Only save audio to the file while the channel is
bridged. *does not include conferences*
a – Append to the file instead of overwriting it.
v(<x>) – Adjust the heard volume by a factor of <x> -4/4.
V(<x>) – Adjust the spoken volume by a factor of <x> -4/4.
W(<x>) – Adjust the overall volume by a factor of <x> -4/4.
E-Learning
• Music on hold is organized in classes
Music on Hold
[default] -> name of the class
mode=files -> files (files,custom,mp3)
directory=moh ->directory where to found the recording in Asterisk format
Applications
MusicOnHold(class,[duration]) -> Play music on hold
Set(CHANNEL(musicclass)=…)-> Set the class for other applications such
as Dial, Queue...
E-Learning
• Application to forward a call
FollowMe
[6000]
context => from-internal
number => 9130523456789,30
number => 9130523456788,30
/etc/asterisk/followme.conf
[from-internal]
exten=6000,1,dial(SIP/Zoiper)
exten=6000,n,followme(6000)
/etc/asterisk/extensions.conf
E-Learning
• In this lecture you have learned how:
– To transfer calls using the Transfer Button
– To transfer calls using *2 in the PBX
– To do attended and unattended transfers
– To pick-up a call
– To park calls
– To create a 3way conference
Summary
E-Learning
Advanced Topics on SIP
E-Learning
• There are some SIP skills that can be useful.
• In this section we will present some of the skills
– To use PJSIP with Asterisk 15 (chan_sip will be
deprecated in the near future)
– chan_sip in depth
Peer matching
Channel naming conventions
– NAT traversal
Connecting phones behind NAT
ALG workarounds
Install Asterisk in the cloud behind NAT
Section overview
E-Learning
• Four chapters borrowed from the training
(Understanding and TroubleShooting SIP)
– Introduction to SIP
– SIP addresses and headers
– Media and Codec Selection
• chan_pjsip
• chan_sip
• NAT traversal
– Running clients behind NAT
– Workarounds for SIP ALG
– Running Asterisk in the Cloud behind NAT
Section development
E-Learning
Using PJSIP
E-Learning
• New features
– Multiple registrations
– Multiple transports
– API friendly, easier to develop and extend
• Problems with chan_sip
– Monolythic
– No oficial support, only community
– Can be officially deprecated in the next version
• Problems with chan_pjsip
– low in adoption
– Configuration is more complex
Why?
E-Learning
Advanced Topics in the Dialplan
E-Learning
• What is important here?
– Context inclusion
– Dialplan processing order
– Time contexts and GotoIfTime
– General section variable autofallthrough
– In depth look at applications
– Persisting data with AstDB
– Limiting simultaneous calls
– Applications extensions language
Section Overview
E-Learning
[local]
exten=_9NXXXXXX,1,Dial(Zap/g1/${EXTEN:1})
[ld]
exten=_91N.,Dial(Zap/g1/${EXTEN:1})
include=>local
[internat]
exten=_9011.,1,Dial(Zap/g1/${EXTEN:1})
include=>ld
Context inclusion
sip.conf extensions.conf
Context inclusion
E-Learning
Dial plan processing order
1. An exact match using dialed number and callerID
2. An exact match using only dialed number
3. A pattern that matches the dialed number
4. A context included in the switch statement
5. An included context
Dialplan processing order
E-Learning
Time based contexts
Time based contexts
E-Learning
Generating Call Detail Record -
CDRs
E-Learning
• What is important here?
– Why generate CDRs
– Hot to generating CDRs
– How to add extra fields
– How to control, reset and avoid CDRs
– How to send CDRS to a database
Section Overview
E-Learning
• Creation
– Channel is created
– Leaves a bridge and is not hungup
– Forked from a prior record
– Enters a multi-party bridge
• Finalized
– Dial completes with status different than ANSWER
– If either party leaves the bridge
– if either channel hangs up
– if CDR is forked
When CDRS are generated
E-Learning
CDR Format
Field Type Description Access
accountcode String (20) An account code r/w
src String (80) The Caller ID Number r
dst String (80) The destination extension r
dcontext String (80) The destination context r
clid String (80) The Caller ID with text r
channel String (80) The name of the Party A channel r
dstchannel String (80) The name of the Party B channel r
lastapp String (80) The last application the Party A executed r
lastdata String (80) The application data for the last application r
start Date/time The time the CDR was created r
answer Date/time The time when Party A was answered r
end Date/time The time when the CDR was finished. r
duration Integer The time in seconds from start until end r
billsec Integer The time in seconds from answer until end r
disposition Enum The final known disposition r
amaflags Enum A flag specified on the Party r/w
uniqueid String (32) A unique identifier for the Party A channel r
E-Learning
• /var/log/asterisk/Master.csv
Standard CDR
E-Learning
Troubleshooting Asterisk
E-Learning
• Troubleshooting Methodology
• How to produce and get data with logs
• Where to get help
• How to get SIP traces
Section Overview
E-Learning
• What is important here?
– What to do when Asterisk does not start
– What to do when a Module does not run
– NoOP() and Verbose()
– Where to find logs and how to rotate them
– How to enable verbose and debug
– Hot to get help
Troubleshooting Asterisk
E-Learning
• Use asterisk –vvvc
– Open in console mode, check if some module
is not loading
What to do when Asterisk does not
start?
E-Learning
• When a module does not load, its commands
don't exist.
– no such command sip show peers is an
example of this case.
– Try to load manually using module load
chan_sip.so
– Check for UDP/TCP port conflicts using netstat
-tanpu
What to do when a module does not
load
E-Learning
Best practices in Asterisk
Security
E-Learning
Agenda
1. How big is the problem?
2. Anatomy of an attack.
3. Types of attacks
4. How to reduce damage if all previous measures failed
E-Learning
How big is the problem?
• AT&T case, 1 million dollar phone bill
Source: https://www.huffpostbrasil.com/entry/michael-smith-att-phone-bill_n_1659136
• Architecture firm received a phone bill of
USD166.000,00
https://www.nytimes.com/2014/10/20/technology/dial-and-redial-phone-hackers-stealing-billions-.html
E-Learning
Anatomy of a simple attack.
Step 1 – Buy a Premium Rate Number
Step 2 – Find a vulnerable VoIP device
And call the premium rate number
Step 3 – Withdrawn in the premium number
E-Learning
E-Learning
Common ways to get a password
1. SIP Scan and Bruteforce
2. TFTP attacks
3. Phone vulnerabilities
4. PBX web interface vulnerabilities
5. Operating System vulnerabilities
Shell Shock, Heartbleed
E-Learning
Under Heavy Attack!
• Basic Scan – sipvicious, friendly-scanner
• Distributed SCAM by W32.Sality virus (discovered by
Symantec/2010)
Source: Symantec http://www.symantec.com/connect/blogs/distributed-cracker-voip
Peer-to-Peer Botnet
Thousands of Corporate PBXs
SIP Scan.
Thousands of
Register Attempts.
E-Learning
SIP Scan Mitigation
• Mandatory strong passwords
– 8 digits minimum, special chars…
• Detect multiple authentication failures
– Block IP with Fail2Ban
• Early detection and discard
– Detect specific signatures and patterns
(IPTABLES)
E-Learning
TFTP Attack
• Trivial Attack against VoIP Infrastructure
– 1st Option bruteforce tftp server
– 2nd Option sniff tftp files using MitM techniques
TFTP Server
Get file 0001234A5B6C.cfg
Plaintext Configuration File
With credentials in plain text
XML or not
Get file 0001234A5B6D.cfg
…
• Solution
– Use HTTPS or Encrypted config files
E-Learning
Attacks on SIP Phones
• How many of you change the default password
for IP phones?
• How many of you update the IP Phone’s
firmware regularly?
Video #1Video #2
E-Learning
Tips to prevent attacks
Easy:
1. Use strong passwords
2. Install and configure iptables
3. Limit SSH to specific addresses or networks
4. Limit HTTP access to specific addresses or networks
5. Change the admin password on phones
Hard:
1. Disable the web interface of the phones
E-Learning
Damage Control
• Face a simple fact, sooner or later, a system
open to the Internet will be compromised.
• The hacker’s advantage
– Administrators have to defend against all attacks,
while one vulnerability is enough for the attacker!
– The administrator is one, attackers are many!
E-Learning
Tips to reduce possible damages?
1. Do not allow all routes to all users.
2. Limit simultaneous calls in International Routes
3. Drop calls after a certain period of time.
4. Use two-way authentication for high-risk international routes
Ex. vmauthenticate(mailbox)
E-Learning
The absolute minimum
Lab. Install iptables and fail2ban
E-Learning
• /var/log/asterisk
• Controlled by the logger.conf
• Log Rotation
Where to find logs
E-Learning
NoOP
Verbose([level,]<message>)
CLI>core set verbose 15
CLI>core set debug 6
Logging your own data
E-Learning
Logger.conf Tour
E-Learning
• Mailing Lists - https://wiki.asterisk.org/wiki/display/AST/Mailing+Lists
• Forum - https://community.asterisk.org/
• Wiki http://wiki.asterisk.org
Getting help
E-Learning
http://issues.asterisk.org
E-Learning
• Do not open if:
– Information Requests (Use mailing list, IRC or wiki)
– Support requests: (Use mailing list, IRC or wiki)
– Random wishes and feature requests with no patch
– Business development requests (Asterisk-biz mailing list)
Opening a support case
E-Learning
• Evidences
– Do you have strong evidence that it is actually a bug?
– Do you have logs and traces?
– Are you using one of the supported versions?
– All dependencies updated?
– Can you reproduce the problem?
– Are you available to test the fixes?
Before opening
E-Learning
• Core Dumps
asterisk –g
Can produce backtraces essential when your
system crashes.
#gdb asterisk corefile
#/var/lib/asterisk/scripts/ast_coredumper core
Debugging
E-Learning
• In this chapter you have learned
– How to troubleshoot the most common cases
– How to enable
• Verbose
• Debug
• Logger
– Where to find help
– How and when to open a Ticket
Summary
E-Learning
cdr_custom
;[mappings]
;Master.csv =>
${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${
CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(l
astdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CD
R(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_
QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}
;
; High Resolution Time for billsec and duration fields
;Master.csv =>
${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${
CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(l
astdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CD
R(duration,f)})},${CSV_QUOTE(${CDR(billsec,f)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV
_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}
;Simple.csv => ${CSV_QUOTE(${EPOCH})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})}
E-Learning
Dispositions
Value Description
NO ANSWER The channel was never answered.
CONGESTION Channel congestion.
FAILED The channel attempted to dial but the call failed
BUSY The remote party was busy.
ANSWERED The channel was answered.
E-Learning
• Accountcode or Billing-id
• Amaflags
– Default
– Omit, do not record calls
– Billing, mark for billing
– Documentation mark for documentation
• You can set amaflags on the channel
– sip.conf, example: amaflags=billing
AMAFLAGS and Account Codes
E-Learning
• cdr_csv
• cdr_custom
• cdr_adpative_odbc
CDR modules
E-Learning
Set(CDR(name)=value)
ResetCDR()
ForkCDR()
CDR associated Functions
E-Learning
DEMO – Sending CDRs to a database
E-Learning
GotoIfTime
GotoIfTime(times,weekdays,mdays,months,[timezone]?[labeliftrue:[labeliffalse]])
Time specification
<time range>,<days of week>,<days of month>,<months>
<time range>= <hour>’:'<minute>’-‘<hour>’:'<minute>|*
<days of week> = <dayname>| <dayname>’-‘<dayname>| “*”
<dayname> = “sun” | “mon” | “tue” | “wed” | “thu” | “fri” | “sat”
<days of month> = <daynum>| <daynum>’-‘<daynum>| “*”
<daynum> = a number, 1 to 31
<hour> = a number, 0 to 23
<minute> = a number, 0 to 59
<months> = <monthname>| <monthname>’-‘<monthname>| “*”
<monthname> = “jan” | “feb” | “mar” | “apr” | “may” | “jun” | “jul” | “aug” | “sep” | “oct” | “nov” | “dec”
E-Learning
GotoIfTime example
GotoIfTime(08:00-18:00,mon-fri,*,*,operator?security);
E-Learning
General section variables
[general]
static=yes ; default = no
writeprotect=no ;default=no
autofallthrough=yes ;default=yes
clearglobalvars=no
priorityjumping=yes
userscontext=default
[globals]
CONSOLE=Zap/1
IAXINFO=guest
TRUNK=Zap/g2
[default]
.
Extensions.conf file structure
E-Learning
In Depth Look at Applications
Applications used in this section
 Dial()
 Answer()
 Hangup()
 Background()
 Gotoif()
 Record()
 Playback()
 Read()
E-Learning
Dial
[Syntax]
Dial(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,options[,U
RL]]])
This application sets the following channel variables:
${DIALEDTIME}: This is the time from dialing a channel until when it is disconnected.
${ANSWEREDTIME}: This is the amount of time for actual call.
${DIALEDPEERNAME}: The name of the outbound channel that answered the call.
${DIALEDPEERNUMBER}: The number that was dialed for the answered outbound channel.
${FORWARDERNAME}: If a call forward occurred, the name of the forwarded channel.
${DIALSTATUS}: This is the status of the call
CHANUNAVAIL
CONGESTION
NOANSWER
BUSY
ANSWER
CANCEL
DONTCALL: For the Privacy and Screening Modes.
TORTURE: For the Privacy and Screening Modes.
INVALIDARGS
E-Learning
The most important Dial options
D([called][:calling[:progress]]): Send the specified DTMF strings *after* the
called party has answered, but before the call gets bridged.
k or K Allow the called or calling party respectively to enable parking of the
call by sending the DTMF sequence defined for call parking in "features.conf".
L(x[:y[:z]]): Limits the maximum call time
x - Maximum call time, in milliseconds
y - Warning time, in milliseconds
z - Repeat time, in milliseconds
r([tone]): Indicate ringing to the calling party (False Ring)
tone - Indicate progress to calling party. Send audio 'tone' from the "indications.conf" tonezone currently in
use.
S(x): Hang up the call <x> seconds *after* the called party has answered the call.
E-Learning
Asterisk Dial options (cont...)
t or T allow the called or calling party respectively to transfer the calling party
by sending the DTMF sequence defined in "features.conf". This setting does
not perform policy enforcement on transfers initiated by other methods.
x or X allow the called or calling party respectively to enable recording of the
call by sending the DTMF sequence defined for one-touch automixmonitor in
"features.conf".
E-Learning
Answer() – Answer a ringing channel
Progress() – Sends a 183 Session Progress
Playback(file,[say,skip,noanswer])
Hangup([causecode]) – Hangup an existing
channel
Answer, Progress,Playback and
Hangup
https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause+Mappings
E-Learning
Play an audio file while waiting for digits of an
extension to go to.
[Description]
Background()
Options
s – skip recording if not answered
n - Don't answer the channel before playing the files.
m - Only break if a digit hit matches a one-digit extension
Background
E-Learning
Read()
Read()
Read a variable
[Description]
maxdigits -- maximum acceptable number of digits.
option
 's' to return immediately if the line is not up,
 'i' to play filename as an indication tone from your indications.conf
 'n' to read digits even if the line is not up
attempts -- if greater than 1, that many attempts will be made
timeout -- An integer number of seconds to wait for a digit response
E-Learning
WaitExten()
[aasiptrunk]
exten=>9999,1,answer()
exten=>9999,n,background(menu1)
exten=>9999,n,waitexten(10)
exten=>9999,n,set(TIMEOUT(response)=10
exten=>9999,n,Dial(${OPERATOR})
exten=>6000,1,Dial(SIP/zoiper)
exten=>6001,1,Dial(SIP/xlite)
E-Learning
Record()
Record to a file
[Description]
Options
'a' : append to existing recording rather than replacing
'n' : do not answer, but record anyway if line not yet answered
'q' : quiet (do not play a beep tone)
's' : skip recording if the line is not yet answered
't' : use alternate '*' terminator key (DTMF) instead of default '#'
'x' : ignore all terminator keys (DTMF) and keep recording until hangup
'format' is the format of the file type to be recorded
'silence' is the number of seconds of silence to allow before returning.
'maxduration' is the maximum recording duration in seconds.
Record
E-Learning
AstDB
Family
KEY1=VALUE
KEY2=VALUE
Functions
variable=${DB(<family/key>)}
DB(<family/key>)=value
DB_EXISTS(<family/key>)
Applications
dbdel(<family/key>)
dbdeltree(<family>)
CLI Commands
database del database put
database show <family[/key]> database showkey
database deltree database get
AstDB
E-Learning
Call Forward. BlackList, DND
[apps]
;call forward immediate
exten=>_*21*XXXX,1,Set(DB(CFIM/${CALLERID(num)})=${EXTEN:4})
exten=>_*21*XXXX,2,Hangup
exten=>*21*,1,DBdel(CFIM/${CALLERID(num)})
exten=>*21*,2,Hangup
;Do not disturb
exten=>_*41*X.,1,Set(DB(dnd/${EXTEN:4})=${EXTEN:4})
exten=>_*41*X.,n,Hangup
exten=>*41*,1,DBdel(dnd/${EXTEN:4})
exten=>*41*,2,Hangup
;call forward on busy status
exten=>_*61*XXXX,1,Set(DB(CFBS/${CALLERID(num)})=${EXTEN:4})
exten=>_*61*XXXX,2,Hangup
exten=>*61*,1,DBdel(CFBS/${CALLERID(num)})
exten=>*61*,2,Hangup
AstDB example
E-Learning
Call Forward. BlackList, DND
AstDB example (Cont)
E-Learning
Applications Extensions Language
extensions.conf extensions.ael
[from-internal]
include=>parkedcalls
exten => _4.,1,Record(${EXTEN:1}:gsm)
exten => _4.,n,wait(1)
exten => _4.,n,Playback(${EXTEN:1})
exten => _4.,n,Hangup()
exten=>6000,1,gosub(stdexten,(SIP/zoiper))
exten=>_9.,1,dial(SIP/${EXTEN:1}@siptrunk,20)
context from-internal {
includes {
parkedcalls;
}
=>_4. {
Record(${EXTEN:1}:gsm);
wait(1);
Playback(${EXTEN:1});
}
=>_6000 { gosub(stdexten(SIP/zoiper));
}
=>_9. { Dial(SIP/${EXTEN:1}@siptrunk,20);
}
E-Learning
Limiting simultaneous calls
exten=>_214X,1,set(GROUP()=Rio)
exten=>_214X,n,Gotoif($[${GROUP_COUNT()} > 1]?overflow)
exten=>_214X,n,Dial(SIP/${EXTEN})
exten=>_214X,n,hangup
exten=>_214X,n(overflow),playback(exceededcalls)
exten=>_214X,n,hangup
E-Learning
• In this section you have learned some of the
most important concepts in the dialplan.
– Context inclusion
– Dialplan processing order
– In depth look at some of the main applications
– Asterisk DB
– Application Extensions Language
– Grouping and limiting calls
Section summary
E-Learning
1. res_pjsip – The main services and the base layer
2. res_pjsip_session – Media session and addons
3. res_pjsip_messaging – text messages
4. res_pjsip_registrar – registrations
5. res_pjsip_pubsub – subscribe/notify/publish
PJSIP modules
E-Learning
1. Endpoints (primary object)
2. AOR (Address of Record)
3. Auth - authentication
4. Transport
5. Registration
6. Identify (By User, IP..., equivalent to peer
matching)
Objects defined in PJSIP
E-Learning
PJSIP entity relationship model
Source: wiki.asterisk.org
https://wiki.asterisk.org/wiki/display/AST/PJSIP+Configuration+Sections+and+Relationships
E-Learning
Transport configuration
[transport-udp-main]
type=transport
protocol=udp
bind=0.0.0.0:5060
[transport-udp-alternative]
type=transport
protocol=udp
bind=0.0.0.0:5080
E-Learning
[xlite]
type=endpoint
transport=transport-udp-main
context=from-internal
disallow=all
allow=ulaw
aors=xlite
auth=xlite
[xlite]
type=auth
auth_type=userpass
username=xlite
password=#supersecret#
[xlite]
type=aor
max_contacts=1
SIP phone configuration
E-Learning
SIP trunk configuration
[siptrunk]
type=endpoint
transport=transport-udp-main
context=from-siptrunk
direct_media=no
disallow=all
allow=ulaw
outbound_auth=siptrunk
aors=siptrunk
[siptrunk]
type=aor
contact=sip:sip.api4com.com:5600
[siptrunk]
type=auth
auth_type=userpass
username=1020
password=supersecret
[siptrunk]
type=registration
outbound_auth=siptrunk
server_uri=sip:1020@sip.api4com.com:5
600
client_uri=sip:1020@sip.api4com.com
contact_user=9999
[siptrunk]
type=identify
endpoint=siptrunk
match=sip.api4com.com
E-Learning
Converting sip.conf on pjsip.conf
sip_to_pjsip.py [options] [input-file [output-file]]
E-Learning
• pjsip console commands tour
PJSIP console commands
E-Learning
• Helpful to troubleshoot SIP
• Excelent article at
https://blogs.asterisk.org/2016/02/24/debugging-
sip-message-traffic-with-pjsip-history/
PJSIP History
E-Learning
exten => _6XXX,1,Dial(PJSIP/${EXTEN})
exten => _6XXX,1,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})})
exten => _9.,1,Dial(PJSIP/siptrunk/sip:${EXTEN:1}@sip.api4com.com)
exten => _9.,1,Dial(PJSIP/${EXTEN:1}@siptrunk)
PJSIP naming conventions
E-Learning
Access Control Lists ACLs
; Define the ACL in pjsip.conf or acl.conf
[acl]
type=acl
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/24
deny=192.168.0.1
; The ACL configuration is independent of individual endpoint configuration and
; operates on all inbound SIP communication using res_pjsip.
E-Learning
• PJSIP is more powerful
– Multiple AORs and Contacts, parallel forking
– Multiple transports
– Easier to extend
– History and Channel Stats
• PJSIP is not simple to use
– Too many objects and sections
– Adoption rate is still very slow
– Less robust, due the lack of a large user base
• No significant performance differences
Comparing channels
E-Learning
• Converting to PJSIP
LAB 5
E-Learning
Additional information
on chan_sip
E-Learning
• By the end of this chapter you should be able to
– Construct a SIP channel acording to the naming
conventions
– Understand how peers are matched for incoming
calls
– Apply the most useful CLI commands to
troubleshoot SIP
– Enable SIP tracing with SIP set debug
– Configure rtptimeout
– Configure QoS tagging
Objectives
E-Learning
• Friend – Entity to send and receive calls
• Peer – Entity to send calls
• User – Entity to receive calls
• Host=dynamic, means it can register
Peer Types
E-Learning
Peer Matching
A TYPE=USER
SECTION EXISTS AND
MATCHES THE “FROM”
HEADER FI ELD?
CHECK
“FROM”HEADER
FIELD IN THE SIP
PACKET
AGAINST THE
SIP.CONF
YE
S
A TYPE=PEER
SECTION EXISTS AND
MATCHES THE IP
ADRESS DEFINED
IN HOSTS=IP
INSECURE=IN
VITE?
YES
ALLOWGUEST ?
TRUE
ALLOW
USE CONTEXT FROM
GENERAL SECTION
FALSE
DENY
NO NO
MD5
CREDENTIALS
ALLOW/DENY
ALLOW
USE CONTEXT
FROM THE
“USER” SECTION
OK
DENY
NOT OK
NO
MD5
CREDENTIALS
ALLOW
USE CONTEXT
FROM PEER
SECTION
OK
DENY
NOT
OK
YE
S
ALLOW
USE CONTEXT
FROM PEER
SECTION
E-Learning
Channel Naming
SIP/[exten@]peer[:portno]
exten => s,1,Dial(SIP/ipphone)
exten => s,1,Dial(SIP/info@voffice.com.br)
exten => s,1,Dial(SIP/192.168.1.8:5060,20)
exten => s,1,Dial(SIP/8500@sip.com:9876)
exten => s,1,Dial(SIP/username:password@sip.com:9876/8500)
E-Learning
Console Commands
; CLI Commands
; -------------------------------------------------------------
; Useful CLI commands to check peers/users:
; sip show peers Show all SIP peers (including friends)
; sip show registry Show status of hosts we register with
;
; sip set debug on Show all SIP messages
;
; sip reload Reload configuration file
; sip show settings Show the current channel configuration
;
E-Learning
SIP debug
• sip det debug on to enable
• sip set debug off to disable
E-Learning
RTP timeout
; The settings are settable in
; the global section as well as per device
;
;rtptimeout=60 ; Terminate call if 60 seconds of no RTP or RTCP activity
; on the audio channel
; when we're not on hold. This is to be able to hangup
; a call in the case of a phone disappearing from the net,
; like a powerloss or grandma tripping over a cable.
;rtpholdtimeout=300 ; Terminate call if 300 seconds of no RTP or RTCP activity
; on the audio channel
; when we're on hold (must be > rtptimeout)
;rtpkeepalive=<secs> ; Send keepalives in the RTP stream to keep NAT open
; (default is off - zero)
E-Learning
Configure QoS tagging
;tos_sip=cs3 ; Sets TOS for SIP packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;tos_video=af41 ; Sets TOS for RTP video packets.
;tos_text=af41 ; Sets TOS for RTP text packets.
;cos_sip=3 ; Sets 802.1p priority for SIP packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
;cos_text=3 ; Sets 802.1p priority for RTP text packets.
E-Learning
NAT on client chan_sip
qualify=yes
directmedia=no
directmedia=nonat
nat=force_rport,comedia
nat = no ; Do no special NAT handling other than RFC3581
nat = force_rport ; Pretend there was an rport parameter even if there wasn't
nat = comedia ; Send media to the port Asterisk received it from regardless
; of where the SDP says to send it.
nat = auto_force_rport ; Set the force_rport option if Asterisk detects NAT (default)
nat = auto_comedia ; Set the comedia option if Asterisk detects NAT
E-Learning
NAT on client PJSIP
[phone]
type=endpoint
direct_media=no
rtp_symmetric=yes
force_rport=yes
[phone]
type=aor
qualify_frequency=15
E-Learning
Server behind NAT on chan_sip
externaddr = 12.34.56.78 ; use this address.
localnet=192.168.0.0/255.255.0.0 ; RFC 1918 addresses
localnet=10.0.0.0/255.0.0.0 ; Also RFC1918
localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation
localnet=169.254.0.0/255.255.0.0 ; Zero conf local network
externhost=foo.dyndns.net ; refreshed periodically
externrefresh=180 ; change the refresh interval
E-Learning
Server behind NAT on PJSIP
[transport-udp-nat]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.0.0/16
external_media_address=203.0.113.1
external_signaling_address=203.0.113.1
external_signaling_port=5060
E-Learning
Application Layer Gateway
• Solves the NAT problem in the router
Workarounds:
Disable ALG in the router
Use a port diferent than 5060
E-Learning
Section Summary
• SIP
• PJSIP
• Advanced Parameters of CHAN_SIP
• NAT Traversal
• NAT Traversal on Client and Server

More Related Content

PPTX
SIP over TLS
Hossein Yavari
 
PPTX
Introduction into SIP protocol
Michal Hrncirik
 
PPT
Sip Detailed , Call flows , Architecture descriptions , SIP services , sip se...
ALTANAI BISHT
 
PPT
Sip
Anirban Roy
 
PPTX
SIP: Call Id, Cseq, Via-branch, From & To-tag role play
Sridhar Kumar N
 
PDF
Asterisk High Availability Design Guide
Michelle Dupuis
 
PDF
Kamailio, FreeSWITCH, and You
Fred Posner
 
PPTX
Session Initiation Protocol
Matt Bynum
 
SIP over TLS
Hossein Yavari
 
Introduction into SIP protocol
Michal Hrncirik
 
Sip Detailed , Call flows , Architecture descriptions , SIP services , sip se...
ALTANAI BISHT
 
SIP: Call Id, Cseq, Via-branch, From & To-tag role play
Sridhar Kumar N
 
Asterisk High Availability Design Guide
Michelle Dupuis
 
Kamailio, FreeSWITCH, and You
Fred Posner
 
Session Initiation Protocol
Matt Bynum
 

What's hot (20)

PPTX
session initiation protocol - SIP
Mahmoud Abudaqa
 
PDF
Getting a live_transcript_of_your_call_using_the_ari
Pascal Cadotte-Michaud
 
PDF
F5 DDoS Protection
MarketingArrowECS_CZ
 
PPTX
FreeSWITCH as a Kickass SBC
Moises Silva
 
PDF
Kamailio - API Based SIP Routing
Daniel-Constantin Mierla
 
PDF
VoLTE Flows and CS network
Karel Berkovec
 
PDF
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Fred Posner
 
PPTX
FastNetMon Advanced DDoS detection tool
Pavel Odintsov
 
PDF
End to End volte ims sip call flow Guide - Mobile originating and Mobile term...
Vikas Shokeen
 
PPTX
Sécurité-Wifi
DAmien Gueg'
 
PDF
F5 Web Application Security
MarketingArrowECS_CZ
 
PDF
ENUM Theory, Implementation, VoIP and Routing SolutionsGary Richenaker
enumplatform
 
PPTX
IPSec VPN & IPSec Protocols
NetProtocol Xpert
 
ODP
Using Asterisk and Kamailio for Reliable, Scalable and Secure Communication S...
Fred Posner
 
PPTX
Using ARI and AGI to Connect Asterisk Instances
Jöran Vinzens
 
PPTX
IMS Authentication with AKAv1 and AKAv2
mohammad norozzudegan
 
PPTX
Linux networking
Arie Bregman
 
PDF
DDoS Mitigation using BGP Flowspec
APNIC
 
DOCX
Type of DDoS attacks with hping3 example
Himani Singh
 
PPT
Chap 12 tcp
Sparsh Samir
 
session initiation protocol - SIP
Mahmoud Abudaqa
 
Getting a live_transcript_of_your_call_using_the_ari
Pascal Cadotte-Michaud
 
F5 DDoS Protection
MarketingArrowECS_CZ
 
FreeSWITCH as a Kickass SBC
Moises Silva
 
Kamailio - API Based SIP Routing
Daniel-Constantin Mierla
 
VoLTE Flows and CS network
Karel Berkovec
 
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Fred Posner
 
FastNetMon Advanced DDoS detection tool
Pavel Odintsov
 
End to End volte ims sip call flow Guide - Mobile originating and Mobile term...
Vikas Shokeen
 
Sécurité-Wifi
DAmien Gueg'
 
F5 Web Application Security
MarketingArrowECS_CZ
 
ENUM Theory, Implementation, VoIP and Routing SolutionsGary Richenaker
enumplatform
 
IPSec VPN & IPSec Protocols
NetProtocol Xpert
 
Using Asterisk and Kamailio for Reliable, Scalable and Secure Communication S...
Fred Posner
 
Using ARI and AGI to Connect Asterisk Instances
Jöran Vinzens
 
IMS Authentication with AKAv1 and AKAv2
mohammad norozzudegan
 
Linux networking
Arie Bregman
 
DDoS Mitigation using BGP Flowspec
APNIC
 
Type of DDoS attacks with hping3 example
Himani Singh
 
Chap 12 tcp
Sparsh Samir
 
Ad

Similar to Asterisk Complete Training (20)

PPT
Asterisk Introduction
King Astreisk Technologies
 
PDF
Asterisk presentation v1.1
Farhan Fuad
 
PPTX
Asterisk Phone Systems
Telephone Wreckers
 
PPT
deploymentofvoipserviceswithasteriskandfreepbx-150730234131-lva1-app6892
Marwen Atallah
 
PDF
SIP Tutorial/Workshop 3
Mihály Mészáros
 
PPT
Astricon 2010: Scaling Asterisk installations
Olle E Johansson
 
DOCX
Linux Telephony
Ryan Ellingson
 
PDF
Ridhwana Mohammad (071403056)
mashiur
 
PPT
Download It
Videoguy
 
ODP
Asterisk ( The open source telephony )
Mohammed Safwat
 
PDF
Telephony Service Development on Asterisk Platform
Hamid Fadishei
 
PDF
Jonny_Martin-Asterisk
tutorialsruby
 
PDF
Jonny_Martin-Asterisk
tutorialsruby
 
PDF
Jonny_Martin-Asterisk
tutorialsruby
 
PDF
Jonny_Martin-Asterisk
tutorialsruby
 
PPT
200706 kathmann shared by voip.com.vn
Tran Thanh
 
PDF
Fatah Uddin (072831056)
mashiur
 
PDF
Asterisk - Glen Bastes
soss
 
KEY
Fun with Linux Telephony
Donald Burr
 
PDF
Setup VoIP System and Interconnection with LTE network
Nazmul Hossain Rakib
 
Asterisk Introduction
King Astreisk Technologies
 
Asterisk presentation v1.1
Farhan Fuad
 
Asterisk Phone Systems
Telephone Wreckers
 
deploymentofvoipserviceswithasteriskandfreepbx-150730234131-lva1-app6892
Marwen Atallah
 
SIP Tutorial/Workshop 3
Mihály Mészáros
 
Astricon 2010: Scaling Asterisk installations
Olle E Johansson
 
Linux Telephony
Ryan Ellingson
 
Ridhwana Mohammad (071403056)
mashiur
 
Download It
Videoguy
 
Asterisk ( The open source telephony )
Mohammed Safwat
 
Telephony Service Development on Asterisk Platform
Hamid Fadishei
 
Jonny_Martin-Asterisk
tutorialsruby
 
Jonny_Martin-Asterisk
tutorialsruby
 
Jonny_Martin-Asterisk
tutorialsruby
 
Jonny_Martin-Asterisk
tutorialsruby
 
200706 kathmann shared by voip.com.vn
Tran Thanh
 
Fatah Uddin (072831056)
mashiur
 
Asterisk - Glen Bastes
soss
 
Fun with Linux Telephony
Donald Burr
 
Setup VoIP System and Interconnection with LTE network
Nazmul Hossain Rakib
 
Ad

More from Flavio Eduardo de Andrade Goncalves (8)

PDF
Asterisk sip channel performance
Flavio Eduardo de Andrade Goncalves
 
PPTX
No More Fraud, Astricon, Las Vegas 2014
Flavio Eduardo de Andrade Goncalves
 
PPTX
No More Fraud Cluecon2014
Flavio Eduardo de Andrade Goncalves
 
PPTX
Number one-issue-voip-today-fraud
Flavio Eduardo de Andrade Goncalves
 
PPT
Asteriskem sistemasembarcados
Flavio Eduardo de Andrade Goncalves
 
PPT
Call Center baseado em Asterisk
Flavio Eduardo de Andrade Goncalves
 
PPTX
Oreka, O Gravador VoIP Open Source
Flavio Eduardo de Andrade Goncalves
 
PPT
Asterisk casosdesucesso
Flavio Eduardo de Andrade Goncalves
 
Asterisk sip channel performance
Flavio Eduardo de Andrade Goncalves
 
No More Fraud, Astricon, Las Vegas 2014
Flavio Eduardo de Andrade Goncalves
 
No More Fraud Cluecon2014
Flavio Eduardo de Andrade Goncalves
 
Number one-issue-voip-today-fraud
Flavio Eduardo de Andrade Goncalves
 
Asteriskem sistemasembarcados
Flavio Eduardo de Andrade Goncalves
 
Call Center baseado em Asterisk
Flavio Eduardo de Andrade Goncalves
 
Oreka, O Gravador VoIP Open Source
Flavio Eduardo de Andrade Goncalves
 
Asterisk casosdesucesso
Flavio Eduardo de Andrade Goncalves
 

Recently uploaded (20)

PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 

Asterisk Complete Training