Dial Plan Order Of Operations

Home » Asterisk Users » Dial Plan Order Of Operations
Asterisk Users 8 Comments

Hello all,

I inherited an Asterisk 1.2 machine and I have a question about the order of operations.

I want to give people the ability to dial specifics and block others. For example, lets say NYC

[allowed]
exten => _1212555., 1,Authenticate(pins||3,j)
exten => _1212555., 2,Dial(SIP/${EXTEN)@mycarrier)
exten => 102,Hangup

exten => _1212.,s,Goto(denied,s,1)

[denied]
exten => s,1,Playback(num-outside-area)
exten => s,2,Hangup

What I would like to do it allow a specific and deny the rest. Mind you the allowed will be everything EXCEPT what is allowed. My question is, will the above work? Please don’t comment on upgrading, this is an inherited system which I cannot update.

8 thoughts on - Dial Plan Order Of Operations

  • Asterisk always tests against the most specific (= hardest-to-match)
    wildcarded extensions first, regardless of the actual order in the dialplan.
    Since _1212555. is harder to match than _1212., the former will be tested first.

  • So then the proper way would be

    [allowed]
    exten => _1212321.,s,Goto(denied,s,1)
    exten => _1212333.,s,Goto(denied,s,1)
    exten => _1212456.,s,Goto(denied,s,1)
    exten => _1212555., 1,Authenticate(pins||3,j)
    exten => _1212555., 2,Dial(SIP/${EXTEN)@mycarrier)
    exten => 102,Hangup

    [denied]
    exten => s,1,Playback(num-outside-area)
    exten => s,2,Hangup

    ?

  • My final question to the list (hopefully) will be, why doesn’t this work as documented (voip-wiki, etc):

    My dialplan (Asterisk 1.2 line)

    exten => _212555.,1,Authenticate(/etc/asterisk/IntlPins||3,j)
    exten => _212555.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212444.,1,Authenticate(/etc/asterisk/IntlPins||3,j)
    exten => _212444.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212333.,1,Authenticate(/etc/asterisk/IntlPins||3,j)
    exten => _212333.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => 102,1,hangup

    When I try calling, I am prompted for the pin, I enter it 3 time and rather than it go to n+101 it allows the call through.

  • From: asterisk-users-bounces@lists.digium.com
    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Asterisk Newb Sent: Monday, September 24, 2012 1:31 PM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: Re: [asterisk-users] Dial plan order of operations

    [allowed]
    exten => _1212321.,s,Goto(denied,s,1)
    exten => _1212333.,s,Goto(denied,s,1)
    exten => _1212456.,s,Goto(denied,s,1)

    exten => _1212555., 1,Authenticate(pins||3,j)
    exten => _1212555., 2,Dial(SIP/${EXTEN)@mycarrier)
    exten => 102,Hangup

    [denied]
    exten => s,1,Playback(num-outside-area)
    exten => s,2,Hangup

    ?

    My final question to the list (hopefully) will be, why doesn’t this work as documented (voip-wiki, etc):

    My dialplan (Asterisk 1.2 line)

    exten => _212555.,1,Authenticate(/etc/asterisk/IntlPins||3,j)

    exten => _212555.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212444.,1,Authenticate(/etc/asterisk/IntlPins||3,j)
    exten => _212444.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212333.,1,Authenticate(/etc/asterisk/IntlPins||3,j)

    exten => _212333.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => 102,1,hangup

    When I try calling, I am prompted for the pin, I enter it 3 time and rather than it go to n+101 it allows the call through.

    Not to be harsh, but the wiki information is “buyer beware” unless it is by one of the developers or a select group of contributors. Lots of things in the wikis “work” as written, but may fail if the wrong tweak is applied.

  • Going to n+101 was deprecated in Asterisk 1.2 or 1.4. Don’t use it.. Read the docs for Authenticate and see what diaplan variables you can check.

    —–Original Message—

  • Thanks, situated the problem with the following:

    exten => _212555.,1,Authenticate(/etc/asterisk/pins||3,j)
    exten => _212555.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212444.,1,Authenticate(/etc/asterisk/pins||3,j)
    exten => _212444.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _212333.,1,Authenticate(/etc/asterisk/pins||3,j)
    exten => _212333.,2,Dial(SIP/${EXTEN:3}@level3,90,tr)

    exten => _X.,102,hangup

    ; exten => 102,1,hangup < --- my screw up So when someone dials a number to a dest (212555{444{333}}) they’re asked for a PIN 3x, if it fails now it hangs up

  • Two suggestions:

    1) Using the ‘n’ priority will make your dialplans more maintainable.

    2) Using a more ‘explicit’ pattern like ‘_212555xxxx’ will result in a more responsive dialplan* because Asterisk ‘knows’ it is looking for a 10
    digit number and won’t have to ‘wait’ to see if it has the whole number.
    (For circuits that don’t deliver the DID/DNIS all at once.)

    Using an ‘open ended’ pattern could also expose you to unexpected outcomes.