Foniva Contact Center Software
Asterisk Experts Support

Asterisk security thread

Few days ago, the FBI send a confusing alert about asterisk and security.

Here is more information about the clarification

On Monday, the Federal Bureau of Investigation (FBI) issued an updated notice regarding the use of Digium’s Asterisk IP PBX for vishing. Now, if they could get the date of posting (Dec. 8) to match the date listed within the notice (Dec. 5), we might actually have a “case closed.”

Make your dialplan readable using priority labels

When you start asterisk or run ‘reload’ or ‘extensions reload’ from asterisk cli, the asterisk process will parse your /etc/asterisk/extensions.conf file and build a list of extensions with priorities starting with 1.

You can give any priority a name and make your extension file easy to write, read and modify.

Here is the syntax for each extension priority

exten => <extension_number>,<priority_number>(<label_name>),<application>(<application_data>)

You can then use the label number into a Goto application instead of an explicit priority number. You can then change your priority number, the label name will be the same and you don’t have to change all Goto places that point to that priority.


exten => 5140000000,1,Noop(New caller from ${CALLERID(all)})

exten => 5140000000,n(playwelcome),Background(welcome-message)

exten => t,1,Noop(User didn’t enter anything… Retry…)

exten => t,n,Goto(5140000000,playwelcome)

In this specific example, the user is asked to enter an extension number. If you don’t enter anything

and reach the t (timeout) extension, we transfer again to extension 5140000000 at priority labelled playwelcome.

Asterisk dialplan : random naviguation

Sometimes, you want your callers to go randomly to a place.

For example, you have 5 extensions and you want inbound calls to be send randomly to those extensions.

You may want a equal distribution or distribution based on a certain probability.

Another case where this can be usefull is if you have multiple carriers and want to send your outbound calls randomly to them.

To do so, you can use the asterisk RAND function.


Choose a random number in a range

Choose a random number between min and max.  Min defaults to 0, if not
specified, while max defaults to RAND_MAX (2147483647 on many systems).
Example:  Set(junky=${RAND(1|8)});
Sets junky to a random number between 1 and 8, inclusive.


In the following example, we receive a call to DID number 5140000000 and want to send 60% to SIP extension 2200 and the rest to extension 3300. The dialplan the looks like

exten => 5140000000,1,Noop(New call received from ${CALLERID(all)})

exten => 5140000000,n,GotoIf($[${RAND(1,100)} > 40]?labelagt1)

exten => 5140000000,n(labelagt2),Dial(SIP/3300)

exten => 5140000000,n,Hangup

exten => 5140000000,n(labelagt1),Dial(SIP/2200)

exten => 5140000000,n,Hangup

So, basicly, when we receive the call, we generate a random number between 0 and 100.

If that number is more than 40 (should happen 60% of the time), we go to priority with label ‘labelagt1′ and we dial SIP/2200.

If not (should happen 40% of the time), we go the next priority and dial SIP/3300.

Our sponsors

Asterisk Experts Support