Voip Think- Voice over IP - Asterisk and SER - SIP IAX and H323

3CX VoIP Phone System, IP PBX for Windows
3CX PBX and Phone System for Windows
Download free edition


  • VoIP Protocols

  • Telephones

  • QoS (Quality of Service)

  • Codecs

  • Asterisk

  • 3CX PBX

  • SER (Sip Express Router)

  • More information


      Asterisk PBX  

        Introduction   linux installation   windows installation   first steps   sip.conf   extensions.conf   voicemail.conf    

    extensions.conf configuration (DialPlan)

    The extensions.conf is the most important Asterisk file and it has the main objective of defining the PBX dialplan for each context and therefore for each user

    The "extensions.conf" file is made up of sections or contexts between brackets [ ]
    There are always two special contexts; [ general ] and [ globals]

    [general] context
    The [general] manages a few general options:

    - static: It indicates if a "save dialplan" command from the console is possible. By default "yes". It works altogether with "writeprotect"
    - writeprotect: If writeprotect=no and static=yes "save dialplan" command from the console is possible. The default value is "no".
    - autofallthrough: If it is activated and an extension is without things to do the call is finished with a BUSY, CONGESTION or HANGUP message If it is not activated it will be waiting for another extension. It is not convenient that an extension remains without things to do as we explain later.
    - clearglobalvars: If it is activated Asterisk release the global variables when the extensions are recharged or when Asterisk is restarted.
    - priorityjumping: with 'yes' value the application supports ' jumping' or jump to different priorities. Deprecated

    [globals] context
    In this context global variables are defined and can be used in the rest of contexts. For example

    CONSOLE=Console/dsp ; when we use CONSOLE word we are calling to /Console/dsp

    Variables usually are always in capital letters to differentiate them later.

    Other contexts[]

    We are going to show now how to create an specific context and to assign it a dialplan. All lines of a certain context have the same format:

    exten =>  extension , priority, Command(parameters)

    Extensión is the caller number
    Priority is the order that commands are run. First the one with priority 1, then with 2, ...
    Command is the thing to do.

    We are going to learn the commands with some examples.

    Example 1: Hangup
    exten => 333,1,Hangup ; when someone calls the number 333 the priority 1 is executed and the system makes a hangup

    Example 2 : Call to 3000 SIP user and if it is not available call the voicemail.
    exten => 3000,1,Dial(SIP/3000,30,Ttm) ; call to the 3000 SIP user that must be defined in sip.conf with that context
    exten => 3000,2,Hangup ; hangup when the call finishs
    exten => 3000,102,Voicemail(3000) ; 102 Priority is when the user is not connected and the voicemail number 3000 starts.
    exten => 3000,103,Hangup ; hangup when the message is left

    To call to 3000 extension we use Dial(destination,timeout time,options) command
    The destination is the user 3000 of the file sip.conf, we have a timeout of 30 seconds. The user 3000 should exist in sip.conf
    The options are options of the dial command:
    "T" allows the user to transfer the call pressing #
    "t" allows the user to transfer the call pressing #
    "m" puts music on hold while we are waiting the other user to respond. You can try without it

    If user 3000 is not connected the systems goes to the actual priority + 101 if it exists (in this case 102) and the voicemail number 3000 starts.

    It is very important that all the branches finish with a hangup command.

    Example 3 : Echo and latency
    exten => 600,1,Playback(demo-echotest) ; Sound of echotest
    exten => 600,2,Echo ; echo test is run
    exten => 600,3,Playback(demo-echodone) ; sound what we said
    exten => 600,4,Hangup ; hangup

    We call number 600 and the things we said are going to be repeated. We can test the latency of the system

    Example 4 : Extension "start"

    exten => s,1,Wait,1 ; Wait a second
    exten => s,2,Answer ; Answer. Asterisk itself get the call
    exten => s,3,DigitTimeout,5 ; Digit Timeout to 5 seconds
    exten => s,4,ResponseTimeout,10 ; Response Timeout to 10 seconds
    exten => s,5,BackGround(demo-congrats) ; A sound archive
    exten => s,6,hangup ; hangup
    exten => 1000,1,Goto(mycontext,s,1) ; When we call 1000 number it goes to s extension with priority 1 of "mycontext"

    In this case we learn the s (start) extension. It is the one that takes the calls when we are in this context but do not know the extension. Also, it is possible to enter from another extension, for example in this case calling to 1000 extension. With Goto we can go to the context, extension and priority that we want.

    Example 5 : Call to a Voip SIP provider

    exten => _340.,1,Dial(SIP/${EXTEN:3}@sipprovider,90,Tt)
    exten => _340.,2,hangup ; hangup

    exten => _20.,1,Dial(SIP/${EXTEN:2}@sipprovider,90,Tt)
    exten => _20.,2,hangup ; hangup

    In this case what we do is that when we call 340 followed by any number (340 is the prefix) we will call to a SIP number. For example in the first case if we press 340600600 number we are calling to the 600600 number of the sipprovider defined in sip.conf. (EXTEN:3 means that we deleted the three first numbers)

    In the second case if we also press 2060600 we will be calling to the same one number "600600" of "sipprovider" (EXTEN:2)

    In the previous cases the point . replaces any character but we can also use
    X - number from 0 to 9
    Z - number from 1 to 9
    N - number from 2 to 9
    [1,5-7] - number 1, 5, 6 or 7

    exten => _20XX,1,Dial(SIP/${EXTEN:2}@sipprovider,90,Tt) ; we must call 20 and two numbers more (no characters)
    exten => _20ZZ.,1,Dial(SIP/${EXTEN:2}@sipprovider,90,Tt) ; we must call 20, and two numbers from 1 to 9 and anything more
    exten => _20[1-3]..,1,Dial(SIP/${EXTEN:2}@sipprovider,90,Tt) ; we must call 20, a number from 1 to 3 and anything more


    Spanish   |   About us    |   Contact   |   Collaborate  |   Advertising