Show Menu
Cheatography

Asterisk Cheat Sheet (DRAFT) by

Asterisk Configuration Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Common config­uration files

sip.conf
Configure trunks
users.conf
Configure users
extens­ion­s.conf
Dialplan config­uration
iax.conf
logger.conf
Files and log levels
confbr­idg­e.conf
Conference bridge config­uration
module­s.conf
musico­nho­ld.conf
Music on hold config­uration
voicem­ail.conf
Voicemail config­uration

Asterisk Console Commands

asterisk -r[vvvv]
Enter Asterisk console [verbose level]
sip show channels
Shows active channels
sip show registry
Display trunk status
sip show peers
Show peer status
core set verbose X
Changes the console verbosity level
core show transl­­ation
Displays transc­oding latency between codecs
reload
Reread the config­uration files, without restarting Asterisk
core restart now
Force Asterisk to restart immedi­ately
core restart gracefully
Restarts Asterisk when calls are complete. New calls are denied
core restart when convenient
Restarts Asterisk when calls are complete. New calls are accepted

Pattern Matching

X
Digit from 0 to 9
Z
Digit from 1 to 9
N
Digit from 2 to 9
.
Wildcard - one or more characters
!
Wildcard - zero or more characters
[ ]
Numeric Range
Examples
 
_1XXX
match from 1000 to 1999
_12[0-5]X
match from 1200 to 1259
_12[015]
match 120, 121 and 125
Complex Match - All Numbers from 4683 to 5132
_468[3-9] ; 4683-4689
_ 469X ; 4690-4699
_ 4[7-9]XX ; 4700-4999
_ 50XX ; 5000-5099
_ 51[0-2]X ; 5100-5129
_ 513[0-2] ; 5130-5132
 

Dialplan Apps

Applic­ation
Descri­ption
Example
Answer()
Answer immedi­ately
Playba­ck(­music)
Play music
Dial(t­ype­/id­ent­ifier, timeout)
Calls the type identifier number for timeout seconds
Dial(S­IP/­Tru­nkN­ame­/${­EXT­EN:3}, 20)
VoiceM­ail­(us­er@­con­text)
Calls the user's voicemail user on context context
VoiceM­ail­(${­EXT­EN}­@my­con­text)
VoiceM­ail­Mai­n(u­ser­@co­ntext)
Allows you to check your voicemail
VoiceM­ail­Mai­n($­CAL­LER­ID(­num­)@m­yco­ntext)
Goto(c­ontext, extension, priority)
Allows you to change context and/or number
Goto(o­the­rCo­ntext, ${EXTE­N:2})
Hangup()
Hang up
NoOp(m­essage)
Does nothing, useful for debugging
NoOp(Call from ${CALL­ERI­D(num)} to ${EXTEN})

Dialplan variables

${EXTEN}
The number called
${CONTEXT}
The name of the current context
${CALL­ERI­D(n­ame)}
The name of the caller
${CALL­ERI­D(num)}
The caller's number

Dialplan Format

Contexts
Keeps different sections of the dialplan indepe­ndent of each other
[users]
Extensions
The series of steps (each containing an applic­ation) defined for that extension
exten => 100,1,­Dia­l(S­IP/­alice)
Priorities
An extension can have multiple steps (prior­ities), which are executed sequen­tially.
exten => 100,1,Playback(tt-weasels)
exten => 100,2,Voicemail(10)
exten => 100,3,Hangup()
 n priority
Automa­tically increases a priority’s value by 1,
exten => 100,1,Playback(tt-weasels)
exten => 100,n,Voicemail(10)
exten => 100,n,Hangup()
same => operator
Enables you to avoid writing the extension on each line, as long the extension remains the same.
exten => 100,1,Playback(tt-weasels)
same => n,Voicemail(10)
same => n,Hangup()
Applic­ations
the action that will be performed on the current channel.
exten => 100,1,­Dia­l(S­IP/­alice)

Manipu­lating Variables

Variable format: ${vari­­ab­l­e­_n­­ame­­[:­o­f­fs­­et[­­:l­e­n­gth]]} where
offset: how many digits to skip (optional)
length: number of digits to return (optional)
Examples: Assuming we've dialed 918005­­551234
1. Remove the first character of extension, save in "­­nu­m­b­er­­" variable.
  exten => _9X.,1­­,S­e­t­(n­­umb­­er­=­$­{E­­XTE­­N:1})
2. Use a negative offset number to remove everything before the last four digits
  exten => _9X.,1­­,S­e­t­(n­­umb­­er­=­$­{E­­XTE­­N:-4})
3. Limit the number of characters from our offset position and only save 555
  exten => _9X.,1­­,S­e­t­(n­­umb­­er­=­$­{E­­XTE­­N:­5:3})
4. The length value can also be used with a negative offset to save 555
  exten => _9X.,1­­,S­e­t­(n­­umb­­er­=­$­{E­­XTE­­N:­-­7:3})
5. Negative length value (-1) will remove # sign from the end of the string.
  exten => _XXXX#­­,1­,­S­et­­(pi­­n=­$­{­EX­­TEN­­:0­:-1})